Alexandro.Net

Download README · GitHub release

@stackline/url

The core url packaged standalone for use with Browserify.

npm version license GitHub repository Docs Reddit community

Documentation | npm | Issues | Repository

Current package version: 1.0.2


Why this package?

@stackline/url is the Stackline-maintained distribution of url@0.11.4. It is an independent continuation of url; original authors and licenses remain credited below.

Compatibility

Item Value
Package @stackline/url@1.0.2
API target url@0.11.4
Supported Node.js >= 0.4
License MIT
Main entry ./url.js
Runtime dependencies qs, punycode

Installation

npm install @stackline/url

Preserve existing imports and plugin resolution with an npm alias:

npm install url@npm:@stackline/url

Usage and API reference

node-url

This module has utilities for URL resolution and parsing meant to have feature parity with node.js core url module.

var url = require('@stackline/url');

api

Parsed URL objects have some or all of the following fields, depending on whether or not they exist in the URL string. Any parts that are not in the URL string will not be in the parsed object. Examples are shown for the URL

'http://user:pass@host.com:8080/p/a/t/h?query=string#hash'

The following methods are provided by the URL module:

url.parse(urlStr, [parseQueryString], [slashesDenoteHost])

Take a URL string, and return an object.

Pass true as the second argument to also parse the query string using the querystring module. Defaults to false.

Pass true as the third argument to treat //foo/bar as { host: 'foo', pathname: '/bar' } rather than { pathname: '//foo/bar' }. Defaults to false.

url.format(urlObj)

Take a parsed URL object, and return a formatted URL string.

url.resolve(from, to)

Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag. Examples:

url.resolve('/one/two/three', 'four')         // '/one/two/four'
url.resolve('http://example.com/', '/one')    // 'http://example.com/one'
url.resolve('http://example.com/one', '/two') // 'http://example.com/two'

Credits and original authors

Original copyright, license notices and contributor acknowledgements remain part of this distribution. Stackline maintenance does not replace authorship of the original work.

License

MIT. See the license and notice files in the repository.

Community and Links

Use this repository's issue tracker for reproducible bugs and feature requests. Join r/Stackline for examples, usage questions and release discussions.