bare-url 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +8 -8
- package/lib/parse.js +5 -5
- package/lib/serialize.js +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -32,11 +32,11 @@ const URL = exports.URL = class URL {
|
|
|
32
32
|
// https://url.spec.whatwg.org/#dom-url-protocol
|
|
33
33
|
|
|
34
34
|
get protocol () {
|
|
35
|
-
return
|
|
35
|
+
return this._url.scheme + ':'
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
set protocol (value) {
|
|
39
|
-
parse(
|
|
39
|
+
parse(value + ':', null, this._url, constants.STATE_SCHEME_START)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// https://url.spec.whatwg.org/#dom-url-username
|
|
@@ -73,7 +73,7 @@ const URL = exports.URL = class URL {
|
|
|
73
73
|
if (this._url.host === null) return ''
|
|
74
74
|
if (this._url.port === null) return this._url.host
|
|
75
75
|
|
|
76
|
-
return
|
|
76
|
+
return this._url.host + ':' + this._url.port
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
set host (value) {
|
|
@@ -101,7 +101,7 @@ const URL = exports.URL = class URL {
|
|
|
101
101
|
get port () {
|
|
102
102
|
if (this._url.port === null) return ''
|
|
103
103
|
|
|
104
|
-
return
|
|
104
|
+
return this._url.port.toString(10)
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
set port (value) {
|
|
@@ -123,7 +123,7 @@ const URL = exports.URL = class URL {
|
|
|
123
123
|
|
|
124
124
|
let output = ''
|
|
125
125
|
|
|
126
|
-
for (const segment of this._url.path) output +=
|
|
126
|
+
for (const segment of this._url.path) output += '/' + segment
|
|
127
127
|
|
|
128
128
|
return output
|
|
129
129
|
}
|
|
@@ -141,7 +141,7 @@ const URL = exports.URL = class URL {
|
|
|
141
141
|
get search () {
|
|
142
142
|
if (this._url.query === null || this._url.query === '') return ''
|
|
143
143
|
|
|
144
|
-
return
|
|
144
|
+
return '?' + this._url.query
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
set search (value) {
|
|
@@ -165,7 +165,7 @@ const URL = exports.URL = class URL {
|
|
|
165
165
|
get hash () {
|
|
166
166
|
if (this._url.fragment === null || this._url.fragment === '') return ''
|
|
167
167
|
|
|
168
|
-
return
|
|
168
|
+
return '#' + this._url.fragment
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
set hash (value) {
|
|
@@ -214,7 +214,7 @@ exports.fileURLToPath = function fileURLToPath (url) {
|
|
|
214
214
|
const pathname = path.normalize(decodeURIComponent(url.pathname))
|
|
215
215
|
|
|
216
216
|
if (os.platform() === 'win32') {
|
|
217
|
-
if (url.hostname) return
|
|
217
|
+
if (url.hostname) return '\\\\' + url.hostname + pathname
|
|
218
218
|
|
|
219
219
|
return pathname.slice(1)
|
|
220
220
|
}
|
package/lib/parse.js
CHANGED
|
@@ -203,7 +203,7 @@ module.exports = function parse (
|
|
|
203
203
|
|
|
204
204
|
// https://url.spec.whatwg.org/#special-authority-ignore-slashes-state
|
|
205
205
|
case constants.STATE_SPECIAL_AUTHORITY_IGNORE_SLASHES:
|
|
206
|
-
if (c !== 0x2f
|
|
206
|
+
if (c !== 0x2f && c !== 0x5c) {
|
|
207
207
|
state = constants.STATE_AUTHORITY
|
|
208
208
|
pointer--
|
|
209
209
|
}
|
|
@@ -412,7 +412,7 @@ module.exports = function parse (
|
|
|
412
412
|
if (isSpecial(url)) {
|
|
413
413
|
state = constants.STATE_PATH
|
|
414
414
|
|
|
415
|
-
if (c !== 0x2f
|
|
415
|
+
if (c !== 0x2f && c !== 0x5c) pointer--
|
|
416
416
|
} else if (!stateOverride && c === 0x3f) {
|
|
417
417
|
url.query = ''
|
|
418
418
|
state = constants.STATE_QUERY
|
|
@@ -438,11 +438,11 @@ module.exports = function parse (
|
|
|
438
438
|
if (isDoubleDotPathSegment(buffer)) {
|
|
439
439
|
shortenPath(url)
|
|
440
440
|
|
|
441
|
-
if (c !== 0x2f
|
|
441
|
+
if (c !== 0x2f && !isSpecial(url) && c === 0x5c) {
|
|
442
442
|
url.path.push('')
|
|
443
443
|
}
|
|
444
444
|
} else if (isSingleDotPathSegment(buffer)) {
|
|
445
|
-
if (c !== 0x2f
|
|
445
|
+
if (c !== 0x2f && !isSpecial(url) && c === 0x5c) {
|
|
446
446
|
url.path.push('')
|
|
447
447
|
}
|
|
448
448
|
} else {
|
|
@@ -543,7 +543,7 @@ function defaultPort (scheme) {
|
|
|
543
543
|
|
|
544
544
|
// https://url.spec.whatwg.org/#is-special
|
|
545
545
|
function isSpecial (url) {
|
|
546
|
-
return isSpecialScheme(url)
|
|
546
|
+
return isSpecialScheme(url.scheme)
|
|
547
547
|
}
|
|
548
548
|
|
|
549
549
|
// https://url.spec.whatwg.org/#include-credentials
|
package/lib/serialize.js
CHANGED
|
@@ -34,7 +34,7 @@ module.exports = function serialize (url, excludeFragment = false) {
|
|
|
34
34
|
if (typeof url.path === 'string') {
|
|
35
35
|
output += url.path
|
|
36
36
|
} else {
|
|
37
|
-
output += '/' +
|
|
37
|
+
for (const segment of url.path) output += '/' + segment
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if (url.query !== null) {
|