| 1 |
'use strict' |
| 2 |
|
| 3 |
const test = require('tape') |
| 4 |
const fastURI = require('../') |
| 5 |
|
| 6 |
const uriJsParseFixtures = require('./fixtures/uri-js-parse.json') |
| 7 |
const uriJsSerializeFixtures = require('./fixtures/uri-js-serialize.json') |
| 8 |
|
| 9 |
test('uri-js compatibility Parse', (t) => { |
| 10 |
uriJsParseFixtures.forEach(( |
| 11 |
[value, expected] |
| 12 |
) => { |
| 13 |
if (value === '//10.10.000.10') { |
| 14 |
return t.skip('Skipping //10.10.000.10 as it is not a valid URI per URI spec: https://datatracker.ietf.org/doc/html/rfc5954#section-4.1') |
| 15 |
} |
| 16 |
if (value.slice(0, 6) === 'mailto') { |
| 17 |
return t.skip('Skipping mailto schema test as it is not supported by fastifyURI') |
| 18 |
} |
| 19 |
t.same(JSON.parse(JSON.stringify(fastURI.parse(value))), expected, 'Compatibility parse: ' + value) |
| 20 |
}) |
| 21 |
t.end() |
| 22 |
}) |
| 23 |
|
| 24 |
test('uri-js compatibility serialize', (t) => { |
| 25 |
uriJsSerializeFixtures.forEach(([value, expected]) => { |
| 26 |
t.same( |
| 27 |
fastURI.serialize(value), |
| 28 |
expected, |
| 29 |
'Compatibility serialize: ' + JSON.stringify(value) |
| 30 |
) |
| 31 |
}) |
| 32 |
t.end() |
| 33 |
}) |