File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11'use strict'
22
3- const UUID_REG = / ^ [ \d a - f ] { 8 } - [ \d a - f ] { 4 } - [ \d a - f ] { 4 } - [ \d a - f ] { 4 } - [ \d a - f ] { 12 } $ / iu
3+ const { isUUID } = require ( './utils' )
44const URN_REG = / ( [ \d a - z ] [ \d \- a - z ] { 0 , 31 } ) : ( (?: [ \w ! $ ' ( ) * + , \- . : ; = @ ] | % [ \d a - f ] { 2 } ) + ) / iu
55
66const supportedSchemeNames = /** @type {const } */ ( [ 'http' , 'https' , 'ws' ,
@@ -162,7 +162,7 @@ function urnuuidParse (urnComponent, options) {
162162 uuidComponents . uuid = uuidComponents . nss
163163 uuidComponents . nss = undefined
164164
165- if ( ! options . tolerant && ( ! uuidComponents . uuid || ! UUID_REG . test ( uuidComponents . uuid ) ) ) {
165+ if ( ! options . tolerant && ( ! uuidComponents . uuid || ! isUUID ( uuidComponents . uuid ) ) ) {
166166 uuidComponents . error = uuidComponents . error || 'UUID is not valid.'
167167 }
168168
Original file line number Diff line number Diff line change 11'use strict'
22
3- const IPV4_REG = / ^ (?: (?: 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] \d | 1 \d { 2 } | [ 1 - 9 ] \d | \d ) \. ) { 3 } (?: 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] \d | 1 \d { 2 } | [ 1 - 9 ] \d | \d ) $ / u
3+ /** @type {(value: string) => boolean } */
4+ const isUUID = RegExp . prototype . test . bind ( / ^ [ \d a - f ] { 8 } - [ \d a - f ] { 4 } - [ \d a - f ] { 4 } - [ \d a - f ] { 4 } - [ \d a - f ] { 12 } $ / iu)
45
56/** @type {(value: string) => boolean } */
6- const isIPv4 = RegExp . prototype . test . bind ( IPV4_REG )
7+ const isIPv4 = RegExp . prototype . test . bind ( / ^ (?: (?: 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] \d | 1 \d { 2 } | [ 1 - 9 ] \d | \d ) \. ) { 3 } (?: 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] \d | 1 \d { 2 } | [ 1 - 9 ] \d | \d ) $ / u )
78
89/**
910 * @param {Array<string> } input
@@ -316,6 +317,7 @@ module.exports = {
316317 normalizeComponentEncoding,
317318 removeDotSegments,
318319 isIPv4,
320+ isUUID,
319321 normalizeIPv6,
320322 stringArrayToHexStripped
321323}
You can’t perform that action at this time.
0 commit comments