Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Groß <kurtextrem@gmail.com>
  • Loading branch information
kurtextrem authored Apr 18, 2024
2 parents a405bde + a85e894 commit b1c84ff
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,6 @@ yarn.lock
# editor files
.vscode
.idea

#tap files
.tap/
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function serialize (cmpts, opts) {
}

if (authority === undefined) {
s = s.replace(/^\/\//, '/%2F') // don't allow the path to start with "//"
s = s.replace(/^\/\//u, '/%2F') // don't allow the path to start with "//"
}

uriTokens.push(s)
Expand All @@ -178,7 +178,7 @@ function serialize (cmpts, opts) {
return uriTokens.join('')
}

const hexLookUp = Array.from({ length: 127 }, (v, k) => /[^!"$&'()*+,.;=_`a-z{}~-]/.test(String.fromCharCode(k)))
const hexLookUp = Array.from({ length: 127 }, (v, k) => /[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(k)))

function nonSimpleDomain (value) {
let code = 0
Expand All @@ -191,7 +191,7 @@ function nonSimpleDomain (value) {
return false
}

const URI_PARSE = /^(?:([^:/?#]+):)?(?:\/\/((?:([^/?#@]*)@)?(\[[^/?#\]]+\]|[^/?#:]*)(?::(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i
const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u

function parse (uri, opts) {
const options = Object.assign({}, opts)
Expand Down
4 changes: 2 additions & 2 deletions lib/schemes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const UUID_REG = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/
const URN_REG = /([A-Za-z0-9][A-Za-z0-9-]{0,31}):((?:[A-Za-z0-9()+,\-.:=@;$_!*']|%[0-9A-Fa-f]{2})+)/
const UUID_REG = /^[\da-f]{8}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{4}\b-[\da-f]{12}$/iu
const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu

function isSecure (wsComponents) {
return typeof wsComponents.secure === 'boolean' ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === 'wss'
Expand Down
10 changes: 5 additions & 5 deletions 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(/^(?:25[0-5]|(?:2[0-4]|1\d|[1-9]|)\d)(?:\.(?:25[0-5]|(?:2[0-4]|1\d|[1-9]|)\d)){3}$/) || []
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 Expand Up @@ -138,10 +138,10 @@ function findToken (str, token) {
return ind
}

const RDS1 = /^\.\.?\//
const RDS2 = /^\/\.(\/|$)/
const RDS3 = /^\/\.\.(\/|$)/
const RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/
const RDS1 = /^\.\.?\//u
const RDS2 = /^\/\.(?:\/|$)/u
const RDS3 = /^\/\.\.(?:\/|$)/u
const RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/u

function removeDotSegments (input) {
const output = []
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "fast-uri",
"description": "Dependency free RFC 3986 URI toolbox",
"version": "2.2.0",
"version": "2.3.0",
"main": "index.js",
"type": "commonjs",
"types": "types/index.d.ts",
"license": "MIT",
"author": "Vincent Le Goff <vince.legoff@gmail.com> (https://github.com/zekth)",
"repository": {
"type": "git",
"url": "https://github.com/fastify/fast-uri"
"url": "git+https://github.com/fastify/fast-uri.git"
},
"bugs": {
"url": "https://github.com/fastify/fast-uri/issues"
},
"homepage":"https://github.com/fastify/fast-uri",
"homepage": "https://github.com/fastify/fast-uri",
"scripts": {
"bench": "node benchmark.js",
"lint:fix": "standard --fix",
Expand All @@ -31,7 +31,7 @@
"snazzy": "^9.0.0",
"standard": "^17.0.0",
"tap": "^16.0.0",
"tsd": "^0.29.0",
"tsd": "^0.31.0",
"uri-js": "^4.4.1"
},
"dependencies": {},
Expand Down

0 comments on commit b1c84ff

Please sign in to comment.