1.0.3 • Published 8 years ago

random-uri v1.0.3

Weekly downloads
29
License
MIT
Repository
github
Last release
8 years ago

random-uri

Return a random url.

MIT License

build:? coverage:?

Install

$ npm install --save random-uri

Usage

For more use-cases see the tests

var randomUrl = require('random-uri');

// API
// - randomUrl(options)

// options
// - protocol
// - domain
// - path
// - extensions
// - query
// - hash

randomUrl();
// => 'http://www.ase.com/pateliivi/kcmd'

Optionally specify a protocol:

randomUrl({protocol: 'ftp'});
// => 'ftp://www.gjiis.cn/lkiund'

Optionally specify a domain:

randomUrl({domain: 'example.com'});
// => http://www.example.com/hob/patecs/fkmsa

Optionally specify a path:

randomUrl({path: 'path/to/file'});
// => 'http://www.ttksd.cn?path/to/file'

Optionally specify a extension:

randomUrl({extensions: '.png'});
randomUrl({extensions: ['gif', 'jpg', 'png']});
// => 'https://ssdda.jp/asdjl/haskljh.png'

Optionally specify a query:

randomUrl({query: 'foo=bar&baz=qux'});
// => 'https://www.asdji.com?foo=bar&baz=qux'

randomUrl({query: { foo: 'bar', baz: 'qux' });
// => 'https://www.drffjo.com?foo=bar&baz=qux'

Optionally specify a hash:

randomUrl({hash: 'readme'});
// => 'https://www.kjksiij.com#readme'

randomUrl({hash: true});
// => 'https://www.jiwhahsud.com#llojsuchej'

Or combine them:

randomUrl({
    protocol: 'http',
    domain: 'example.com',
    path: 'path/to/file',
    extensions: ['gif', 'jpg', 'png']
    query: { foo: 'bar', baz: 'qux' },
    hash: true
};

// => 'http://example.com/path/to/file.png?foo=bar&baz=qux#ksijahs'

Related

Contributing

Pull requests and stars are highly welcome.

For bugs and feature requests, please create an issue.