Debian Codegraph @

fast-uri/test/security-normalization.test.js

raw
1 'use strict'
2
3 const test = require('tape')
4 const fastURI = require('..')
5
6 test('parse preserves reserved path escapes as data', (t) => {
7 const components = fastURI.parse('http://example.com/a%2Fb/public/%2e%2e/admin')
8
9 t.equal(components.path, '/a%2Fb/public/%2E%2E/admin')
10 t.end()
11 })
12
13 test('normalize preserves percent-encoded path separators and dot segments', (t) => {
14 t.equal(
15 fastURI.normalize('http://example.com/public/%2e%2e/admin'),
16 'http://example.com/public/%2E%2E/admin'
17 )
18
19 t.equal(
20 fastURI.normalize('http://example.com/a%2Fb'),
21 'http://example.com/a%2Fb'
22 )
23
24 t.end()
25 })
26
27 test('equal does not treat reserved path escapes as live path syntax', (t) => {
28 t.equal(
29 fastURI.equal('http://example.com/public/%2e%2e/admin', 'http://example.com/admin', {}),
30 false
31 )
32
33 t.equal(
34 fastURI.equal('http://example.com/a%2Fb', 'http://example.com/a/b', {}),
35 false
36 )
37
38 t.end()
39 })