Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A small utility for parsing URLs of all types.
tree: 9afabba92a

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tests
README.md
parsely.js

README.md

Parsley is a JavaScript URL-parser for breaking down both simple and complex URL strings into their component elements. This is achieved primarily through regular expressions with iteration used for extending the break-down of query, path and hash portions of a URL.

usage:

var parts = parsely( url ); //parsely('http://google.com');

Supported URL patterns include:

"http:",
"https://",
"http://host",
"http://host/",
"http://host.com",
"http://subdomain.host.com",
"http://host.com:81",
"http://user@host.com",
"http://user@host.com:81",
"http://user:@host.com",
"http://user:@host.com:81",
"http://user:pass@host.com",
"http://user:pass@host.com:81",
"http://user:pass@host.com:81?query",
"http://user:pass@host.com:81#anchor",
"http://user:pass@host.com:81/",
"http://user:pass@host.com:81/?query",
"http://user:pass@host.com:81/#anchor",
"http://user:pass@host.com:81/file.ext",
"http://user:pass@host.com:81/directory",
"http://user:pass@host.com:81/directory?query",
"http://user:pass@host.com:81/directory#anchor",
"http://user:pass@host.com:81/directory/",
"http://user:pass@host.com:81/directory/?query",
"http://user:pass@host.com:81/directory/#anchor",
"http://user:pass@host.com:81/directory/sub.directory/",
"http://user:pass@host.com:81/directory/sub.directory/file.ext",
"http://user:pass@host.com:81/directory/file.ext?query",
"http://user:pass@host.com:81/directory/file.ext?query=1&test=2",
"http://user:pass@host.com:81/directory/file.ext?query=1#anchor",
"//host.com",
"//user:pass@host.com:81/direc.tory/file.ext?query=1&test=2#anchor/anchor2",
"/directory/sub.directory/file.ext?query=1&test=2#anchor",
"/directory/",
"/file.ext",
"/?query",
"/#anchor",
"/",
"?query",
"?query=1&test=2#anchor",
"#anchor",
"path/to/file",
"localhost",
"192.168.1.1",
"host.com",
"host.com:81",
"host.com:81/",
"host.com?query",
"host.com#anchor",
"host.com/",
"host.com/file.ext",
"host.com/directory/?query",
"host.com/directory/#anchor",
"host.com/directory/file.ext",
"host.com:81/direc.tory/file.ext?query=1&test=2#anchor",
"user@host.com",
"user@host.com:81",
"user@host.com/",
"user@host.com/file.ext",
"user@host.com?query",
"user@host.com#anchor",
"user:pass@host.com:81/direc.tory/file.ext?query=1&test=2#anchor"

Due to the need for testing to factor in more than just the correct number of objects output, tests might take another few days to wrap up but they are coming.

Something went wrong with that request. Please try again.