random-uri
v1.0.3
Published
Return a random url.
Downloads
721
Maintainers
Readme
random-uri
Return a random url.
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
- random-tld - Return a random tld(Top Level Domain).
- random-domains - Return a random domain.
- random-email - Return a random email.
- random-protocol - Return a random protocol.
- random-hashtag - Return a random hashtag.
- random-ipv4 - Return a random ipv4 address.
- random-ipv6 - Return a random ipv6 address.
- random-avatar - Return a URL to a random avatar from Gravatar.
Contributing
Pull requests and stars are highly welcome.
For bugs and feature requests, please create an issue.