Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

url parsing utility

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 History.md
Octocat-spinner-32 Makefile
Octocat-spinner-32 Readme.md
Octocat-spinner-32 component.json
Octocat-spinner-32 index.js
Readme.md

url

url parser.

Installation

$ component install component/url

Example

var url = require('url');
url.parse('http://example.com:3000/store/shoes?sort=desc');

yields:

{
  hash: ""
  host: "example.com:3000"
  port: 3000,
  hostname: "example.com"
  href: "http://example.com:3000/store/shoes?sort=desc"
  pathname: "/store/shoes"
  protocol: "http:"
  query: "sort=desc"
  search: "?sort=desc"
}

API

url.parse(string)

Parse the given url string.

url.isAbsolute(string)

Check if the given url string is absolute (has a scheme specified).

url.isRelative(string)

Check if the given url string is relative.

url.isCrossDomain(string)

Check if the given url string is cross-domain.

Note

This url "parser" uses an A tag, this means that when a relative url is given, such as "/foo", it becomes relative to the current domain / path, because the browser resolves it as it normally would.

License

MIT

Something went wrong with that request. Please try again.