Sign In

fast-uri

Package Overview
Dependencies
Maintainers
11
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-uri - npm Package Compare versions

Comparing version
3.1.2
to
3.1.3
+1
-1
index.js

@@ -308,3 +308,3 @@ 'use strict'

try {
parsed.host = URL.domainToASCII(parsed.host.toLowerCase())
parsed.host = new URL('http://' + parsed.host).hostname
} catch (e) {

@@ -311,0 +311,0 @@ parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e

{
"name": "fast-uri",
"description": "Dependency-free RFC 3986 URI toolbox",
"version": "3.1.2",
"version": "3.1.3",
"main": "index.js",

@@ -6,0 +6,0 @@ "type": "commonjs",

@@ -134,1 +134,29 @@ 'use strict'

})
test('parse canonicalises IDN / Unicode hosts to their ASCII form', (t) => {
const cases = [
{
input: 'http://127。0。0。1/',
expectedHost: '127.0.0.1',
description: 'full-width ideographic stops as octet separators'
},
{
input: 'http://example.com/',
expectedHost: 'example.com',
description: 'fullwidth e as first letter'
},
{
input: 'http://納豆.example.org/',
expectedHost: 'xn--99zt52a.example.org',
description: 'CJK label requiring punycode'
}
]
t.plan(cases.length * 2)
cases.forEach(({ input, expectedHost, description }) => {
const parsed = fastURI.parse(input)
t.notOk(parsed.error, `parse should not set error: ${description}`)
t.equal(parsed.host, expectedHost, `host canonicalised to ASCII: ${description}`)
})
})