All Projects → addyosmani → parsely

addyosmani / parsely

Licence: other
A small utility for parsing URLs of all types.

Programming Languages

javascript
184084 projects - #8 most used programming language

#Parsely.js

Parsley is a JavaScript URL parser for breaking down both simple and complex URL strings into their component parts. 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 ); //e.g. parsely('http://google.com');

###Supported URL patterns:

"http:",
"https://",
"http://host",
"http://host/",
"http://host.com",
"http://subdomain.host.com",
"http://host.com:81",
"http://[email protected]",
"http://[email protected]:81",
"http://user:@host.com",
"http://user:@host.com:81",
"http://user:[email protected]",
"http://user:[email protected]:81",
"http://user:[email protected]:81?query",
"http://user:[email protected]:81#anchor",
"http://user:[email protected]:81/",
"http://user:[email protected]:81/?query",
"http://user:[email protected]:81/#anchor",
"http://user:[email protected]:81/file.ext",
"http://user:[email protected]:81/directory",
"http://user:[email protected]:81/directory?query",
"http://user:[email protected]:81/directory#anchor",
"http://user:[email protected]:81/directory/",
"http://user:[email protected]:81/directory/?query",
"http://user:[email protected]:81/directory/#anchor",
"http://user:[email protected]:81/directory/sub.directory/",
"http://user:[email protected]:81/directory/sub.directory/file.ext",
"http://user:[email protected]:81/directory/file.ext?query",
"http://user:[email protected]:81/directory/file.ext?query=1&test=2",
"http://user:[email protected]:81/directory/file.ext?query=1#anchor",
"//host.com",
"//user:[email protected]: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",
"[email protected]",
"[email protected]:81",
"[email protected]/",
"[email protected]/file.ext",
"[email protected]?query",
"[email protected]#anchor",
"user:[email protected]:81/direc.tory/file.ext?query=1&test=2#anchor"

Parsely comes complete with a number of unit tests.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].