Urls are, at their heart, serialised data-structures. They're really awkward to work with, and everyone in the web-world has seen god-awful regex hacks in one project or another. We don't use string manipulation on JSON, though; so why subject ourselves to it for urls?
API
ureal.parse(url) -> object
Like JSON.parse
, ureal.parse
takes a string (a url), and turns it into a userful datastructure. For instance:
ureal
Returns:
protocol: 'https' user: 'user' password: 'password' domain: 'secure.my-site.com' path: 'profile' params: edit: 'email'
ureal.stringify(object) -> url
ureal.stringify
takes an object in the same format as ureal.parse
emits, and constructs a url out of it:
ureal
Returns:
'https://user:password@secure.my-site.com/profile?edit=email'```g