You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.1 KiB
54 lines
1.1 KiB
3 months ago
|
# url
|
||
|
|
||
|
```js
|
||
|
// usage
|
||
|
chance.url()
|
||
|
chance.url({protocol: 'ftp'})
|
||
|
chance.url({domain: 'www.socialradar.com'})
|
||
|
chance.url({domain_prefix: 'docs'})
|
||
|
chance.url({path: 'images'})
|
||
|
chance.url({extensions: ['gif', 'jpg', 'png']})
|
||
|
```
|
||
|
|
||
|
Return a random url.
|
||
|
|
||
|
```js
|
||
|
chance.url()
|
||
|
=> 'http://vanogsi.io/pateliivi'
|
||
|
```
|
||
|
|
||
|
Optionally specify a protocol and the url will be random but the protocol will not.
|
||
|
|
||
|
```js
|
||
|
chance.url({protocol: 'ftp'})
|
||
|
=> 'ftp://mibfu.nr/kardate'
|
||
|
```
|
||
|
|
||
|
Optionally specify a domain and the url will be random but the domain will not.
|
||
|
|
||
|
```js
|
||
|
chance.url({domain: 'www.socialradar.com'})
|
||
|
=> 'http://www.socialradar.com/hob'
|
||
|
```
|
||
|
|
||
|
Optionally specify a domain prefix and domain will be random, and domain prefix will not.
|
||
|
|
||
|
```js
|
||
|
chance.url({domain_prefix: 'docs'})
|
||
|
=> 'http://docs.tuos.ni/itecabup'
|
||
|
```
|
||
|
|
||
|
Optionally specify a path and it will be obeyed.
|
||
|
|
||
|
```js
|
||
|
chance.url({path: 'images'})
|
||
|
=> 'http://tainvoz.net/images'
|
||
|
```
|
||
|
|
||
|
Optionally specify an array of extensions and one will be picked at random.
|
||
|
|
||
|
```js
|
||
|
chance.url({extensions: ['gif', 'jpg', 'png']})
|
||
|
=> 'http://vagjiup.gov/udmopke.png'
|
||
|
```
|