Monday, February 12th, 2007

parseUri: Another JavaScript URL parser

Category: JavaScript, Library

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?

Posted by Dion Almaer at 5:28 am
Comment here

4.2 rating from 49 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.