url-sanitizer 5.2.0 → 5.2.2
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 +10 -12
- package/dist/url-sanitizer-wo-dompurify.min.js +1 -1
- package/dist/url-sanitizer-wo-dompurify.min.js.map +3 -3
- package/dist/url-sanitizer.min.js +3 -3
- package/dist/url-sanitizer.min.js.map +3 -3
- package/package.json +8 -8
- package/src/index.js +43 -18
- package/src/mjs/constant.js +16 -0
- package/src/mjs/dompurify.js +2 -2
- package/src/mjs/filter.js +48 -43
- package/src/mjs/sanitize.js +59 -94
- package/src/mjs/scheme.js +2 -2
- package/src/mjs/text-chars.js +1 -1
- package/types/index.d.ts +29 -14
- package/types/mjs/constant.d.ts +1 -0
- package/types/mjs/filter.d.ts +11 -7
- package/types/mjs/sanitize.d.ts +7 -41
package/types/index.d.ts
CHANGED
|
@@ -6,10 +6,30 @@
|
|
|
6
6
|
* @see {@link https://github.com/asamuzaK/urlSanitizer/blob/main/LICENSE}
|
|
7
7
|
*/
|
|
8
8
|
import { URLSanitizer } from './mjs/sanitize.js';
|
|
9
|
-
export type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export type InspectedDataURL = {
|
|
10
|
+
base64: boolean;
|
|
11
|
+
data: string;
|
|
12
|
+
mime: string;
|
|
13
|
+
};
|
|
14
|
+
export type InspectedURLResult = {
|
|
15
|
+
input: string;
|
|
16
|
+
valid: boolean;
|
|
17
|
+
href: string | null;
|
|
18
|
+
relative?: boolean;
|
|
19
|
+
reason?: string;
|
|
20
|
+
data?: InspectedDataURL | null;
|
|
21
|
+
origin?: string;
|
|
22
|
+
protocol?: string;
|
|
23
|
+
username?: string;
|
|
24
|
+
password?: string;
|
|
25
|
+
host?: string;
|
|
26
|
+
hostname?: string;
|
|
27
|
+
port?: string;
|
|
28
|
+
pathname?: string;
|
|
29
|
+
search?: string;
|
|
30
|
+
hash?: string;
|
|
31
|
+
};
|
|
32
|
+
export type SanitizeOptions = {
|
|
13
33
|
allow?: string[];
|
|
14
34
|
deny?: string[];
|
|
15
35
|
only?: string[];
|
|
@@ -18,16 +38,11 @@ export declare const sanitizeURL: (url: string, opt?: {
|
|
|
18
38
|
revokeObjectURL?: boolean;
|
|
19
39
|
maxBlobSize?: number;
|
|
20
40
|
maxLength?: number;
|
|
21
|
-
}
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
allowRelative?: boolean;
|
|
27
|
-
debug?: boolean;
|
|
28
|
-
revokeObjectURL?: boolean;
|
|
29
|
-
maxLength?: number;
|
|
30
|
-
}) => string | null;
|
|
41
|
+
};
|
|
42
|
+
export { URLSanitizer };
|
|
43
|
+
declare const sanitizer: URLSanitizer;
|
|
44
|
+
export declare const sanitizeURL: (url: string, opt?: SanitizeOptions) => Promise<string | null>;
|
|
45
|
+
export declare const sanitizeURLSync: (url: string, opt?: SanitizeOptions) => string | null;
|
|
31
46
|
export declare const inspectURL: (url: string) => Promise<InspectedURLResult>;
|
|
32
47
|
export declare const isValidURI: (uri: string) => boolean;
|
|
33
48
|
export declare const isURISync: (uri: string) => boolean;
|
package/types/mjs/constant.d.ts
CHANGED
package/types/mjs/filter.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
export type DOMPurify = import('dompurify').DOMPurify;
|
|
2
|
+
export type InspectedDataURL = import('../index.js').InspectedDataURL;
|
|
3
|
+
export type InspectedURLResult = import('../index.js').InspectedURLResult;
|
|
4
|
+
export type SanitizeOptions = import('../index.js').SanitizeOptions;
|
|
5
|
+
export type InternalSanitizeOptions = import('./sanitize.js').InternalSanitizeOptions;
|
|
1
6
|
export declare class SanitizeContext {
|
|
2
7
|
#private;
|
|
3
|
-
domPurify:
|
|
8
|
+
domPurify: import("dompurify").DOMPurify;
|
|
4
9
|
nest: number;
|
|
5
10
|
recurse: Set<any>;
|
|
6
11
|
restrictScheme: boolean;
|
|
7
12
|
schemeMap: Map<string, boolean>;
|
|
8
13
|
allowRelative: boolean | undefined;
|
|
9
14
|
debug: boolean | undefined;
|
|
10
|
-
|
|
11
|
-
constructor(opt: object, domPurifyInstance: object);
|
|
15
|
+
constructor(domPurifyInstance: DOMPurify, opt?: InternalSanitizeOptions);
|
|
12
16
|
private #compileRules;
|
|
13
17
|
private #registerScheme;
|
|
14
18
|
enter(url: string): boolean;
|
|
@@ -16,13 +20,13 @@ export declare class SanitizeContext {
|
|
|
16
20
|
}
|
|
17
21
|
export declare class SanitizeFilter {
|
|
18
22
|
#private;
|
|
19
|
-
constructor(
|
|
23
|
+
constructor(opt?: InternalSanitizeOptions);
|
|
20
24
|
private #process;
|
|
21
25
|
private #sanitizeDataURL;
|
|
22
26
|
private #purify;
|
|
23
27
|
private #handleSanitizeAttribute;
|
|
24
28
|
private #sanitizeStandardURL;
|
|
25
|
-
sanitize(url: string,
|
|
26
|
-
sanitizeBuffer(buffer: ArrayBuffer, mimeType: string,
|
|
27
|
-
sanitizeDataURL(url: string,
|
|
29
|
+
sanitize(url: string, opt?: InternalSanitizeOptions): string | null;
|
|
30
|
+
sanitizeBuffer(buffer: ArrayBuffer, mimeType: string, opt?: InternalSanitizeOptions): Promise<string | null>;
|
|
31
|
+
sanitizeDataURL(url: string, opt?: InternalSanitizeOptions): Promise<string | null>;
|
|
28
32
|
}
|
package/types/mjs/sanitize.d.ts
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
import { URISchemes } from './scheme.js';
|
|
2
|
-
export type InspectedDataURL =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export type InspectedURLResult = {
|
|
8
|
-
input: string;
|
|
9
|
-
valid: boolean;
|
|
10
|
-
href: string | null;
|
|
11
|
-
relative?: boolean;
|
|
12
|
-
reason?: string;
|
|
13
|
-
data?: InspectedDataURL | null;
|
|
14
|
-
origin?: string;
|
|
15
|
-
protocol?: string;
|
|
16
|
-
username?: string;
|
|
17
|
-
password?: string;
|
|
18
|
-
host?: string;
|
|
19
|
-
hostname?: string;
|
|
20
|
-
port?: string;
|
|
21
|
-
pathname?: string;
|
|
22
|
-
search?: string;
|
|
23
|
-
hash?: string;
|
|
2
|
+
export type InspectedDataURL = import('../index.js').InspectedDataURL;
|
|
3
|
+
export type InspectedURLResult = import('../index.js').InspectedURLResult;
|
|
4
|
+
export type SanitizeOptions = import('../index.js').SanitizeOptions;
|
|
5
|
+
export type InternalSanitizeOptions = SanitizeOptions & {
|
|
6
|
+
schemes?: Set<string>;
|
|
24
7
|
};
|
|
25
8
|
export declare class URLSanitizer extends URISchemes {
|
|
26
9
|
#private;
|
|
@@ -33,25 +16,8 @@ export declare class URLSanitizer extends URISchemes {
|
|
|
33
16
|
add(scheme: string): string[];
|
|
34
17
|
remove(scheme: string): boolean;
|
|
35
18
|
reset(): void;
|
|
36
|
-
sanitizeURL(url: string, opt?:
|
|
37
|
-
|
|
38
|
-
deny?: string[];
|
|
39
|
-
only?: string[];
|
|
40
|
-
allowRelative?: boolean;
|
|
41
|
-
debug?: boolean;
|
|
42
|
-
revokeObjectURL?: boolean;
|
|
43
|
-
maxBlobSize?: number;
|
|
44
|
-
maxLength?: number;
|
|
45
|
-
}): Promise<string | null>;
|
|
46
|
-
sanitizeURLSync(url: string, opt?: {
|
|
47
|
-
allow?: string[];
|
|
48
|
-
deny?: string[];
|
|
49
|
-
only?: string[];
|
|
50
|
-
allowRelative?: boolean;
|
|
51
|
-
debug?: boolean;
|
|
52
|
-
revokeObjectURL?: boolean;
|
|
53
|
-
maxLength?: number;
|
|
54
|
-
}): string | null;
|
|
19
|
+
sanitizeURL(url: string, opt?: SanitizeOptions): Promise<string | null>;
|
|
20
|
+
sanitizeURLSync(url: string, opt?: SanitizeOptions): string | null;
|
|
55
21
|
inspectURL(url: string): Promise<InspectedURLResult>;
|
|
56
22
|
isValidURI(uri: string): boolean;
|
|
57
23
|
}
|