Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/component/url
url parsing utility
https://github.com/component/url
Last synced: about 2 months ago
JSON representation
url parsing utility
- Host: GitHub
- URL: https://github.com/component/url
- Owner: component
- Created: 2012-09-07T23:07:29.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2015-06-18T10:22:54.000Z (over 9 years ago)
- Last Synced: 2024-06-27T09:38:55.278Z (3 months ago)
- Language: JavaScript
- Size: 190 KB
- Stars: 47
- Watchers: 5
- Forks: 12
- Open Issues: 4
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# url
url parser.
## Installation
$ component install component/url
## Example
```js
var url = require('url');
url.parse('http://example.com:3000/store/shoes?sort=desc');
```yields:
```js
{
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 `` 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