url-sanitizer 0.1.1 → 0.1.4
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 +6 -12
- package/package.json +1 -1
- package/src/mjs/uri-util.js +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/asamuzaK/urlSanitizer/actions?query=workflow%3Abuild)
|
|
4
4
|
[](https://github.com/asamuzaK/urlSanitizer/actions?query=workflow%3Agithub-code-scanning%3Acodeql)
|
|
5
|
-
|
|
5
|
+

|
|
6
6
|
|
|
7
7
|
URL sanitizer for Node.js (>=18), browsers and web sites.
|
|
8
8
|
**Experimental**
|
|
@@ -13,14 +13,11 @@ URL sanitizer for Node.js (>=18), browsers and web sites.
|
|
|
13
13
|
npm i url-sanitizer
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
For browsers and web sites, standalone
|
|
16
|
+
For browsers and web sites, standalone ESM builds are available in `dist/` directory.
|
|
17
17
|
* node_modules/url-sanitizer/dist/url-sanitizer.js
|
|
18
18
|
* node_modules/url-sanitizer/dist/url-sanitizer.min.js
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
Or, download directly from unpkg.com
|
|
22
|
-
*
|
|
23
|
-
-->
|
|
20
|
+
Or, download the source code from [Releases](https://github.com/asamuzaK/urlSanitizer/releases).
|
|
24
21
|
|
|
25
22
|
## Usage
|
|
26
23
|
|
|
@@ -88,7 +85,8 @@ Determines whether the given URI is valid.
|
|
|
88
85
|
|
|
89
86
|
* `uri` **[string][1]** URI input
|
|
90
87
|
|
|
91
|
-
Returns **[Promise][5]<[boolean][3]
|
|
88
|
+
Returns **[Promise][5]<[boolean][3]>** result
|
|
89
|
+
* Always `true` for `web+*` and/or `ext+*` schemes
|
|
92
90
|
|
|
93
91
|
```javascript
|
|
94
92
|
const res1 = await isURI('https://example.com/foo');
|
|
@@ -114,7 +112,7 @@ Synchronous version of the [isURI()](#isuriuri).
|
|
|
114
112
|
|
|
115
113
|
Get an array of URI schemes registered at [iana.org](https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml "Uniform Resource Identifier (URI) Schemes").
|
|
116
114
|
* Historical schemes omitted.
|
|
117
|
-
* `moz-extension` scheme added
|
|
115
|
+
* `moz-extension` scheme added.
|
|
118
116
|
|
|
119
117
|
Returns **[Array][2]<[string][1]>** array of registered URI schemes
|
|
120
118
|
|
|
@@ -132,7 +130,6 @@ Check if the given scheme is registered.
|
|
|
132
130
|
* `scheme` **[string][1]** scheme
|
|
133
131
|
|
|
134
132
|
Returns **[boolean][3]** result
|
|
135
|
-
* Always `true` for `web+*` and/or `ext+*` schemes
|
|
136
133
|
|
|
137
134
|
```javascript
|
|
138
135
|
const res1 = urlSanitizer.has('https');
|
|
@@ -140,9 +137,6 @@ const res1 = urlSanitizer.has('https');
|
|
|
140
137
|
|
|
141
138
|
const res2 = urlSanitizer.has('foo');
|
|
142
139
|
// -> false
|
|
143
|
-
|
|
144
|
-
const res3 = uriSanitizer.has('web+foo');
|
|
145
|
-
// -> true
|
|
146
140
|
```
|
|
147
141
|
|
|
148
142
|
### urlSanitizer.add(scheme)
|
package/package.json
CHANGED
package/src/mjs/uri-util.js
CHANGED
|
@@ -110,7 +110,7 @@ export class URISchemes {
|
|
|
110
110
|
*
|
|
111
111
|
* @see {@link https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml}
|
|
112
112
|
* - Historical schemes omitted
|
|
113
|
-
* -
|
|
113
|
+
* - 'moz-extension' scheme added
|
|
114
114
|
* @returns {Array.<string>} - array of schemes
|
|
115
115
|
*/
|
|
116
116
|
get() {
|