encodeurl 2.0.0 → 2.0.1
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/README.md +14 -0
- package/index.js +5 -10
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Encode URL
|
|
2
2
|
|
|
3
|
+
[![NPM Version][npm-image]][npm-url]
|
|
4
|
+
[![NPM Downloads][downloads-image]][downloads-url]
|
|
5
|
+
[![Build Status][ci-image]][ci-url]
|
|
6
|
+
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
7
|
+
|
|
3
8
|
Encode a URL to a percent-encoded form, excluding already-encoded sequences.
|
|
4
9
|
|
|
5
10
|
## Installation
|
|
@@ -107,3 +112,12 @@ $ npm run lint
|
|
|
107
112
|
## License
|
|
108
113
|
|
|
109
114
|
[MIT](LICENSE)
|
|
115
|
+
|
|
116
|
+
[npm-image]: https://img.shields.io/npm/v/encodeurl
|
|
117
|
+
[npm-url]: https://npmjs.org/package/encodeurl
|
|
118
|
+
[downloads-image]: https://img.shields.io/npm/dm/encodeurl
|
|
119
|
+
[downloads-url]: https://npmcharts.com/compare/encodeurl?minimal=true
|
|
120
|
+
[ci-image]: https://img.shields.io/github/actions/workflow/status/pillarjs/encodeurl/ci.yml?branch=master
|
|
121
|
+
[ci-url]: https://github.com/pillarjs/encodeurl/actions/workflows/ci.yml
|
|
122
|
+
[coveralls-image]: https://img.shields.io/coverallsCoverage/github/pillarjs/encodeurl?branch=master
|
|
123
|
+
[coveralls-url]: https://coveralls.io/r/pillarjs/encodeurl?branch=master
|
package/index.js
CHANGED
|
@@ -22,18 +22,11 @@ module.exports = encodeUrl
|
|
|
22
22
|
var ENCODE_CHARS_REGEXP = /(?:[^\x21\x23-\x3B\x3D\x3F-\x5F\x61-\x7A\x7C\x7E]|%(?:[^0-9A-Fa-f]|[0-9A-Fa-f][^0-9A-Fa-f]|$))+/g
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* RegExp to match
|
|
25
|
+
* RegExp to match surrogate pairs and unpaired surrogates.
|
|
26
26
|
* @private
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* String to replace unmatched surrogate pair with.
|
|
33
|
-
* @private
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
var UNMATCHED_SURROGATE_PAIR_REPLACE = '$1\uFFFD$2'
|
|
29
|
+
var SURROGATE_REGEXP = /([\uD800-\uDBFF][\uDC00-\uDFFF])|[\uD800-\uDFFF]/g
|
|
37
30
|
|
|
38
31
|
/**
|
|
39
32
|
* Encode a URL to a percent-encoded form, excluding already-encoded sequences.
|
|
@@ -55,6 +48,8 @@ var UNMATCHED_SURROGATE_PAIR_REPLACE = '$1\uFFFD$2'
|
|
|
55
48
|
|
|
56
49
|
function encodeUrl (url) {
|
|
57
50
|
return String(url)
|
|
58
|
-
.replace(
|
|
51
|
+
.replace(SURROGATE_REGEXP, function (_, pair) {
|
|
52
|
+
return pair || '\uFFFD'
|
|
53
|
+
})
|
|
59
54
|
.replace(ENCODE_CHARS_REGEXP, encodeURI)
|
|
60
55
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "encodeurl",
|
|
3
3
|
"description": "Encode a URL to a percent-encoded form, excluding already-encoded sequences",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Douglas Christopher Wilson <doug@somethingdoug.com>"
|
|
7
7
|
],
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"url"
|
|
13
13
|
],
|
|
14
14
|
"repository": "pillarjs/encodeurl",
|
|
15
|
+
"funding": {
|
|
16
|
+
"type": "opencollective",
|
|
17
|
+
"url": "https://opencollective.com/express"
|
|
18
|
+
},
|
|
15
19
|
"devDependencies": {
|
|
16
20
|
"eslint": "5.11.1",
|
|
17
21
|
"eslint-config-standard": "12.0.0",
|
|
@@ -19,8 +23,8 @@
|
|
|
19
23
|
"eslint-plugin-node": "7.0.1",
|
|
20
24
|
"eslint-plugin-promise": "4.0.1",
|
|
21
25
|
"eslint-plugin-standard": "4.0.0",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
26
|
+
"mocha": "~11.7.0",
|
|
27
|
+
"nyc": "~17.1.0"
|
|
24
28
|
},
|
|
25
29
|
"files": [
|
|
26
30
|
"LICENSE",
|
|
@@ -33,8 +37,8 @@
|
|
|
33
37
|
},
|
|
34
38
|
"scripts": {
|
|
35
39
|
"lint": "eslint .",
|
|
36
|
-
"test": "mocha --
|
|
37
|
-
"test-
|
|
38
|
-
"test-
|
|
40
|
+
"test": "mocha --check-leaks --reporter spec",
|
|
41
|
+
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
|
42
|
+
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
|
39
43
|
}
|
|
40
44
|
}
|