summaryrefslogtreecommitdiff
path: root/bin/wiki/ImportarDesdeURL/node_modules/is-uri/test/index.js
blob: e8fa8902205cc04350518117e5adcdfcf1b6c0bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* global describe, it */

'use strict'

var isURI = require('..')
var should = require('should')

var URLS = {
  VALID: [
    'http://google.com',
    'http://localhost/',
    'http://example.w3.org/path%20with%20spaces.html',
    'http://example.w3.org/%20',
    'ftp://ftp.is.co.za/rfc/rfc1808.txt',
    'ftp://ftp.is.co.za/../../../rfc/rfc1808.txt',
    'http://www.ietf.org/rfc/rfc2396.txt',
    'ldap://[2001:db8::7]/c=GB?objectClass?one',
    'mailto:John.Doe@example.com',
    'news:comp.infosystems.www.servers.unix',
    'tel:+1-816-555-1212',
    'telnet://192.0.2.16:80/',
    'urn:oasis:names:specification:docbook:dtd:xml:4.1.2',
    'https://🐀.ws/🐀🐀',
    'magnet:?xt=urn:sha1:PDAQRAOQQRYS76MRZJ33LK4MMVZBDSCL'
  ],
  INVALID: [
    5,
    null,
    undefined,
    true,
    NaN,
    {},
    [],
    function () {},
    '',
    'foo',
    'foo@bar', // no scheme
    '://foo/', // empty scheme
    '1http://foo', // invalid scheme
    'http://<foo>', // illegals
    'http:////foo.html', // invalid path,
    'http://example.w3.org/%illegal.html',
    'http://example.w3.org/%a', // incomplete hex escape
    'http://example.w3.org/%a/foo', // incomplete hex escape,
    'http://example.w3.org/%at' // incomplete hex escape
  ]
}

describe('parse uri', function () {
  it('valid', function () {
    URLS.VALID.forEach(function (url) {
      isURI(url, {strictMode: true}).should.be.true()
    })
  })

  it('invalid', function () {
    URLS.INVALID.forEach(function (url) {
      isURI(url, {strictMode: true}).should.be.false()
    })
  })
})