PHP Classes
elePHPant
Icontem

URL Normalizer: Normalize URLs according to RFC 3986

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2011-05-05 (4 years ago) RSS 2.0 feedNot enough user ratingsTotal: 773 All time: 4,108 This week: 1,153Up
Version License PHP version Categories  
url-normalizer 1.0BSD License5.0PHP 5, Text processing
Description Author  

This class can be used to normalize URLs according to RFC 3986.

It can take a given URL and may fix it to perform syntax based normalization.

Specifically it may lower the case hexadecimal codes of encoded characters, decode characters which are not reserved, removed unnecessary relative path segments, and lower case of the URL scheme and host name.

Innovation Award  
PHP Programming Innovation award nominee
February 2011
Number 2


Prize: One subscription to the PDF edition of the PHP Architect magazine
Sometimes the users enter URLs that despite browsers will accept them, they are not completely valid.

This class can normalize those URLs using RFC 3986 rules to make the URLs strictly valid.

Manuel Lemos
Picture of Glen Scott
Name: Glen Scott <contact>
Classes: 1 package by
Country: United Kingdom United Kingdom
Age: ???
All time rank: 2481112 in United Kingdom United Kingdom
Week rank: 1577 Up75 in United Kingdom United Kingdom Up
Innovation award
Innovation award
Nominee: 1x

Details provided by the author  
Syntax based normalization of URI's

This normalises URI's based on the specification RFC 3986 
http://www.apps.ietf.org/rfc/rfc3986.html

Example usage:
<code>
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"
</code>

TODO:

Add further scheme-based normalization steps, as detailed in section 6.2.3 of the RFC.
  Files folder image Files  
File Role Description
Plain text file URLNormalizer.php Class Main class
Accessible without login Plain text file URLNormalizerTest.php Test Test class
Accessible without login Plain text file test-client.php Example Example script
Accessible without login Plain text file README Doc. README

 Version Control Unique User Downloads Download Rankings  
 0%Total:773All time:4,108
 This week:0This week:1,153Up
 User Comments (2)