I’ve posted to GitHub a PHP class that I’ve written which can handle URL normalization, as specified by RFC 3986.
https://github.com/glenscott/url-normalizer
Specifically, the following normalization steps are performed:
- Normalize case
- Decode unreserved characters
- Remove dot segments
An example of use:
require_once 'URLNormalizer.php'; $url = 'eXAMPLE://a/./b/../b/%63/%7bfoo%7d'; $un = new URLNormalizer(); $un->setUrl( $url ); echo $un->normalize(); // result: "example://a/b/c/%7Bfoo%7D"
Nice work! I was just about to write something like this to clean up user-provided URLs. 🙂 You rock.
Hey, your github repro does not provide informations about licensing.
I would like to add your URLNormalizer class to a wordpress plugin/framework i’m developing witch is available under the GNUv2 License.
Would that be okay for you?
I’ve been meaning to add a BSD licence for some time. Feel free to use it in your GPL project.
Nice, thanks for your work!