parseUri: Another JavaScript URL parser
Written by on February 12th, 2007 in Ajax News.
Steven Levithan saw the Poly9’s Polyvalent Javascript URL Parser and thinks he has done one better.
He created parseUri and thinks it has advantages:
- Ability to split the directory path and file name.
- If a path component was present in the source URL, it will always return a trailing slash as the last character in the directoryPath component (this is easy to remove if a user does not want this functionality).
- Offers convenient, pre-concatenated commonly used component pairs (authority = domain + port; path = directoryPath + fileName).
- Much lighter weight (literally only a few lines of code).
- Cleaner syntax (e.g., parseUri(someUri).port).
- Unlike the alternative code, it does not include an extemely weak and flawed attempt at validation.
- It’s much more flexible, since all URL components are optional.
- Uses cleaner regular expression syntax.
- More closly follows the generic URI syntax spec set in RFC 3986
- Available in JavaScript and ColdFusion implementations.
So, Is there any leaner, meaner URI parser out there?
Source: Ajaxian
Original Article: http://ajaxian.com/archives/parseuri-another-javascript-url-parser