@@ -27,8 +27,8 @@ function isValidSchemeName (name) {
2727 * @typedef {Object } SchemeHandler
2828 * @property {SchemeName } scheme - The scheme name.
2929 * @property {boolean } [domainHost] - Indicates if the scheme supports domain hosts.
30- * @property {SchemeFn } parse - Function to parse the URI components for this scheme.
31- * @property {SchemeFn } serialize - Function to serialize the URI components for this scheme.
30+ * @property {SchemeFn } parse - Function to parse the URI component for this scheme.
31+ * @property {SchemeFn } serialize - Function to serialize the URI component for this scheme.
3232 * @property {boolean } [skipNormalize] - Indicates if normalization should be skipped for this scheme.
3333 * @property {boolean } [absolutePath] - Indicates if the scheme uses absolute paths.
3434 * @property {boolean } [unicodeSupport] - Indicates if the scheme supports Unicode.
@@ -56,33 +56,33 @@ function wsIsSecure (wsComponent) {
5656}
5757
5858/** @type {SchemeFn } */
59- function httpParse ( components ) {
60- if ( ! components . host ) {
61- components . error = components . error || 'HTTP URIs must have a host.'
59+ function httpParse ( component ) {
60+ if ( ! component . host ) {
61+ component . error = component . error || 'HTTP URIs must have a host.'
6262 }
6363
64- return components
64+ return component
6565}
6666
6767/** @type {SchemeFn } */
68- function httpSerialize ( components ) {
69- const secure = String ( components . scheme ) . toLowerCase ( ) === 'https'
68+ function httpSerialize ( component ) {
69+ const secure = String ( component . scheme ) . toLowerCase ( ) === 'https'
7070
7171 // normalize the default port
72- if ( components . port === ( secure ? 443 : 80 ) || components . port === '' ) {
73- components . port = undefined
72+ if ( component . port === ( secure ? 443 : 80 ) || component . port === '' ) {
73+ component . port = undefined
7474 }
7575
7676 // normalize the empty path
77- if ( ! components . path ) {
78- components . path = '/'
77+ if ( ! component . path ) {
78+ component . path = '/'
7979 }
8080
8181 // NOTE: We do not parse query strings for HTTP URIs
8282 // as WWW Form Url Encoded query strings are part of the HTML4+ spec,
8383 // and not the HTTP spec.
8484
85- return components
85+ return component
8686}
8787
8888/** @type {SchemeFn } */
@@ -99,95 +99,95 @@ function wsParse (wsComponent) {
9999}
100100
101101/** @type {SchemeFn } */
102- function wsSerialize ( wsComponents ) {
102+ function wsSerialize ( wsComponent ) {
103103// normalize the default port
104- if ( wsComponents . port === ( wsIsSecure ( wsComponents ) ? 443 : 80 ) || wsComponents . port === '' ) {
105- wsComponents . port = undefined
104+ if ( wsComponent . port === ( wsIsSecure ( wsComponent ) ? 443 : 80 ) || wsComponent . port === '' ) {
105+ wsComponent . port = undefined
106106 }
107107
108108 // ensure scheme matches secure flag
109- if ( typeof wsComponents . secure === 'boolean' ) {
110- wsComponents . scheme = ( wsComponents . secure ? 'wss' : 'ws' )
111- wsComponents . secure = undefined
109+ if ( typeof wsComponent . secure === 'boolean' ) {
110+ wsComponent . scheme = ( wsComponent . secure ? 'wss' : 'ws' )
111+ wsComponent . secure = undefined
112112 }
113113
114114 // reconstruct path from resource name
115- if ( wsComponents . resourceName ) {
116- const [ path , query ] = wsComponents . resourceName . split ( '?' )
117- wsComponents . path = ( path && path !== '/' ? path : undefined )
118- wsComponents . query = query
119- wsComponents . resourceName = undefined
115+ if ( wsComponent . resourceName ) {
116+ const [ path , query ] = wsComponent . resourceName . split ( '?' )
117+ wsComponent . path = ( path && path !== '/' ? path : undefined )
118+ wsComponent . query = query
119+ wsComponent . resourceName = undefined
120120 }
121121
122122 // forbid fragment component
123- wsComponents . fragment = undefined
123+ wsComponent . fragment = undefined
124124
125- return wsComponents
125+ return wsComponent
126126}
127127
128128/** @type {SchemeFn } */
129- function urnParse ( urnComponents , options ) {
130- if ( ! urnComponents . path ) {
131- urnComponents . error = 'URN can not be parsed'
132- return urnComponents
129+ function urnParse ( urnComponent , options ) {
130+ if ( ! urnComponent . path ) {
131+ urnComponent . error = 'URN can not be parsed'
132+ return urnComponent
133133 }
134- const matches = urnComponents . path . match ( URN_REG )
134+ const matches = urnComponent . path . match ( URN_REG )
135135 if ( matches ) {
136- const scheme = options . scheme || urnComponents . scheme || 'urn'
137- urnComponents . nid = matches [ 1 ] . toLowerCase ( )
138- urnComponents . nss = matches [ 2 ]
139- const urnScheme = `${ scheme } :${ options . nid || urnComponents . nid } `
136+ const scheme = options . scheme || urnComponent . scheme || 'urn'
137+ urnComponent . nid = matches [ 1 ] . toLowerCase ( )
138+ urnComponent . nss = matches [ 2 ]
139+ const urnScheme = `${ scheme } :${ options . nid || urnComponent . nid } `
140140 const schemeHandler = getSchemeHandler ( urnScheme )
141- urnComponents . path = undefined
141+ urnComponent . path = undefined
142142
143143 if ( schemeHandler ) {
144- urnComponents = schemeHandler . parse ( urnComponents , options )
144+ urnComponent = schemeHandler . parse ( urnComponent , options )
145145 }
146146 } else {
147- urnComponents . error = urnComponents . error || 'URN can not be parsed.'
147+ urnComponent . error = urnComponent . error || 'URN can not be parsed.'
148148 }
149149
150- return urnComponents
150+ return urnComponent
151151}
152152
153153/** @type {SchemeFn } */
154- function urnSerialize ( urnComponents , options ) {
155- const scheme = options . scheme || urnComponents . scheme || 'urn'
156- const nid = urnComponents . nid . toLowerCase ( )
154+ function urnSerialize ( urnComponent , options ) {
155+ const scheme = options . scheme || urnComponent . scheme || 'urn'
156+ const nid = urnComponent . nid . toLowerCase ( )
157157 const urnScheme = `${ scheme } :${ options . nid || nid } `
158158 const schemeHandler = getSchemeHandler ( urnScheme )
159159
160160 if ( schemeHandler ) {
161- urnComponents = schemeHandler . serialize ( urnComponents , options )
161+ urnComponent = schemeHandler . serialize ( urnComponent , options )
162162 }
163163
164- const uriComponents = urnComponents
165- const nss = urnComponents . nss
166- uriComponents . path = `${ nid || options . nid } :${ nss } `
164+ const uriComponent = urnComponent
165+ const nss = urnComponent . nss
166+ uriComponent . path = `${ nid || options . nid } :${ nss } `
167167
168168 options . skipEscape = true
169- return uriComponents
169+ return uriComponent
170170}
171171
172172/** @type {SchemeFn } */
173173function urnuuidParse ( urnComponent , options ) {
174- const uuidComponents = urnComponent
175- uuidComponents . uuid = uuidComponents . nss
176- uuidComponents . nss = undefined
174+ const uuidComponent = urnComponent
175+ uuidComponent . uuid = uuidComponent . nss
176+ uuidComponent . nss = undefined
177177
178- if ( ! options . tolerant && ( ! uuidComponents . uuid || ! isUUID ( uuidComponents . uuid ) ) ) {
179- uuidComponents . error = uuidComponents . error || 'UUID is not valid.'
178+ if ( ! options . tolerant && ( ! uuidComponent . uuid || ! isUUID ( uuidComponent . uuid ) ) ) {
179+ uuidComponent . error = uuidComponent . error || 'UUID is not valid.'
180180 }
181181
182- return uuidComponents
182+ return uuidComponent
183183}
184184
185185/** @type {SchemeFn } */
186- function urnuuidSerialize ( uuidComponents ) {
187- const urnComponents = uuidComponents
186+ function urnuuidSerialize ( uuidComponent ) {
187+ const urnComponent = uuidComponent
188188 // normalize UUID
189- urnComponents . nss = ( uuidComponents . uuid || '' ) . toLowerCase ( )
190- return urnComponents
189+ urnComponent . nss = ( uuidComponent . uuid || '' ) . toLowerCase ( )
190+ return urnComponent
191191}
192192
193193const http = /** @type {SchemeHandler } */ ( {
0 commit comments