Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge next into main #92

Merged
merged 4 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:

jobs:
test:
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.2.0
with:
license-check: true
node-versions: '["16", "18", "20"]'
2 changes: 1 addition & 1 deletion .github/workflows/package-manager-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ on:

jobs:
test:
uses: fastify/workflows/.github/workflows/plugins-ci-package-manager.yml@v3
uses: fastify/workflows/.github/workflows/plugins-ci-package-manager.yml@v4.1.0
4 changes: 3 additions & 1 deletion .taprc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
check-coverage: false
disable-coverage: true
files:
- test/**/*.test.js
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { HEX } = require('./scopedChars')

function normalizeIPv4 (host) {
if (findToken(host, '.') < 3) { return { host, isIPV4: false } }
const matches = host.match(/^(\b[01]?\d{1,2}|\b2[0-4]\d|\b25[0-5])(\.([01]?\d{1,2}|2[0-4]\d|25[0-5])){3}$/u) || []
const matches = host.match(/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/u) || []
const [address] = matches
if (address) {
return { host: stripLeadingZeros(address, '.'), isIPV4: true }
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@
"homepage": "https://github.com/fastify/fast-uri",
"scripts": {
"bench": "node benchmark.js",
"lint": "standard | snazzy",
"lint:fix": "standard --fix",
"test:lint": "standard | snazzy",
"test:typescript": "tsd",
"test:unit": "tap -J test/*.test.js",
"test:unit:dev": "tap -J test/*.test.js --coverage-report=html",
"test": "npm run test:lint && npm run test:unit && npm run test:typescript",
"test:ci": "npm run test:lint && npm run test:unit -- --cov --coverage-report=lcovonly && npm run test:typescript"
"test": "npm run lint && npm run test:unit && npm run test:typescript",
"test:ci": "npm run lint && npm run test:unit -- --coverage-report=lcovonly && npm run test:typescript",
"test:unit": "tap",
"test:unit:dev": "npm run test:unit -- --coverage-report=html",
"test:typescript": "tsd"
},
"devDependencies": {
"@fastify/pre-commit": "^2.1.0",
"benchmark": "^2.1.4",
"coveralls": "^3.1.1",
"snazzy": "^9.0.0",
"standard": "^17.0.0",
"tap": "^16.0.0",
"standard": "^17.1.0",
"tap": "^18.7.2",
"tsd": "^0.31.0",
"uri-js": "^4.4.1"
}
Expand Down
2 changes: 1 addition & 1 deletion test/compatibility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test('compatibility Parse', (t) => {
'//www.g.com/error\n/bleh/bleh',
'https://fastify.org',
'//10.10.10.10',
'//10.10.000.10',
// '//10.10.000.10', <-- not a valid URI per URI spec: https://datatracker.ietf.org/doc/html/rfc5954#section-4.1
'//[2001:db8::7%en0]',
'//[2001:dbZ::1]:80',
'//[2001:db8::1]:80',
Expand Down
15 changes: 12 additions & 3 deletions test/parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,21 @@ test('URI parse', (t) => {
t.equal(components.query, undefined, 'query')
t.equal(components.fragment, undefined, 'fragment')

// IPv4address with unformated 0
components = URI.parse('//10.10.000.10')
// IPv4address with unformated 0 stay as-is
components = URI.parse('//10.10.000.10') // not valid as per https://datatracker.ietf.org/doc/html/rfc5954#section-4.1
t.equal(components.error, undefined, 'IPv4address errors')
t.equal(components.scheme, undefined, 'scheme')
t.equal(components.userinfo, undefined, 'userinfo')
t.equal(components.host, '10.10.0.10', 'host')
t.equal(components.host, '10.10.000.10', 'host')
t.equal(components.port, undefined, 'port')
t.equal(components.path, '', 'path')
t.equal(components.query, undefined, 'query')
t.equal(components.fragment, undefined, 'fragment')
components = URI.parse('//01.01.01.01') // not valid in URIs: https://datatracker.ietf.org/doc/html/rfc3986#section-7.4
t.equal(components.error, undefined, 'IPv4address errors')
t.equal(components.scheme, undefined, 'scheme')
t.equal(components.userinfo, undefined, 'userinfo')
t.equal(components.host, '01.01.01.01', 'host')
t.equal(components.port, undefined, 'port')
t.equal(components.path, '', 'path')
t.equal(components.query, undefined, 'query')
Expand Down
Loading