@drawbridge/drawbridge-utils 0.0.72 → 0.0.74
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/dist/sanitize.cjs +8 -2
- package/dist/sanitize.d.cts +26 -5
- package/dist/sanitize.d.ts +26 -5
- package/dist/sanitize.js +7 -2
- package/package.json +1 -1
package/dist/sanitize.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var sanitize_exports = {};
|
|
|
31
31
|
__export(sanitize_exports, {
|
|
32
32
|
sanitizeDomain: () => sanitizeDomain,
|
|
33
33
|
sanitizeEmail: () => sanitizeEmail,
|
|
34
|
+
sanitizeHttps: () => sanitizeHttps,
|
|
34
35
|
sanitizeQueries: () => sanitizeQueries,
|
|
35
36
|
sanitizeString: () => sanitizeString,
|
|
36
37
|
sanitizeUrl: () => sanitizeUrl
|
|
@@ -82,9 +83,13 @@ var sanitizeDomain = (value, pattern) => {
|
|
|
82
83
|
}
|
|
83
84
|
return cleaned;
|
|
84
85
|
};
|
|
86
|
+
var sanitizeHttps = (val) => {
|
|
87
|
+
const value = val == null ? void 0 : val.replace(/^(https?:\/\/)+/i, "");
|
|
88
|
+
return value ? "https://" + value : "";
|
|
89
|
+
};
|
|
85
90
|
var sanitizeUrl = (url) => {
|
|
86
|
-
|
|
87
|
-
return (
|
|
91
|
+
if (!url) return url;
|
|
92
|
+
return sanitizeHttps(url).replace(/^https:\/\/www\./, "https://").replace(/\/$/, "");
|
|
88
93
|
};
|
|
89
94
|
var sanitizeEmail = (raw) => {
|
|
90
95
|
if (typeof raw !== "string") return {
|
|
@@ -127,6 +132,7 @@ var sanitizeQueries = (req, res, next) => {
|
|
|
127
132
|
0 && (module.exports = {
|
|
128
133
|
sanitizeDomain,
|
|
129
134
|
sanitizeEmail,
|
|
135
|
+
sanitizeHttps,
|
|
130
136
|
sanitizeQueries,
|
|
131
137
|
sanitizeString,
|
|
132
138
|
sanitizeUrl
|
package/dist/sanitize.d.cts
CHANGED
|
@@ -89,10 +89,31 @@ const sanitizeDomain = ( value, pattern ) => {
|
|
|
89
89
|
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
// Coerce a value to a canonical https prefix: strips ALL leading http(s)://
|
|
93
|
+
// occurrences (case-insensitive — a doubled prefix from re-submitted input
|
|
94
|
+
// self-heals) then prepends https://. Keystroke-safe, so the same helper
|
|
95
|
+
// backs app-web's InputUrl and server routes that accept submitted urls.
|
|
96
|
+
const sanitizeHttps = ( val ) => {
|
|
97
|
+
|
|
98
|
+
const value = val?.replace( /^(https?:\/\/)+/i, '' );
|
|
99
|
+
|
|
100
|
+
return value ? 'https://' + value : '';
|
|
101
|
+
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Full write-path normalizer for finished urls: canonical https prefix
|
|
105
|
+
// (via sanitizeHttps — regex.url validation alone still lets a doubled
|
|
106
|
+
// https://https:// prefix through), then strip www. and any trailing slash.
|
|
107
|
+
// Keystroke-time inputs want sanitizeHttps alone — this one fights typing.
|
|
108
|
+
const sanitizeUrl = ( url ) => {
|
|
109
|
+
|
|
110
|
+
if( ! url ) return url;
|
|
111
|
+
|
|
112
|
+
return sanitizeHttps( url )
|
|
113
|
+
.replace( /^https:\/\/www\./, 'https://' )
|
|
114
|
+
.replace( /\/$/, '' );
|
|
115
|
+
|
|
116
|
+
};
|
|
96
117
|
|
|
97
118
|
// Normalize + validate an email address. Trim, lowercase, basic shape
|
|
98
119
|
// check, and reject disposable-domain providers. Returns the normalized
|
|
@@ -171,4 +192,4 @@ const sanitizeQueries = ( req, res, next ) => {
|
|
|
171
192
|
|
|
172
193
|
};
|
|
173
194
|
|
|
174
|
-
export { sanitizeDomain, sanitizeEmail, sanitizeQueries, sanitizeString, sanitizeUrl };
|
|
195
|
+
export { sanitizeDomain, sanitizeEmail, sanitizeHttps, sanitizeQueries, sanitizeString, sanitizeUrl };
|
package/dist/sanitize.d.ts
CHANGED
|
@@ -89,10 +89,31 @@ const sanitizeDomain = ( value, pattern ) => {
|
|
|
89
89
|
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
// Coerce a value to a canonical https prefix: strips ALL leading http(s)://
|
|
93
|
+
// occurrences (case-insensitive — a doubled prefix from re-submitted input
|
|
94
|
+
// self-heals) then prepends https://. Keystroke-safe, so the same helper
|
|
95
|
+
// backs app-web's InputUrl and server routes that accept submitted urls.
|
|
96
|
+
const sanitizeHttps = ( val ) => {
|
|
97
|
+
|
|
98
|
+
const value = val?.replace( /^(https?:\/\/)+/i, '' );
|
|
99
|
+
|
|
100
|
+
return value ? 'https://' + value : '';
|
|
101
|
+
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Full write-path normalizer for finished urls: canonical https prefix
|
|
105
|
+
// (via sanitizeHttps — regex.url validation alone still lets a doubled
|
|
106
|
+
// https://https:// prefix through), then strip www. and any trailing slash.
|
|
107
|
+
// Keystroke-time inputs want sanitizeHttps alone — this one fights typing.
|
|
108
|
+
const sanitizeUrl = ( url ) => {
|
|
109
|
+
|
|
110
|
+
if( ! url ) return url;
|
|
111
|
+
|
|
112
|
+
return sanitizeHttps( url )
|
|
113
|
+
.replace( /^https:\/\/www\./, 'https://' )
|
|
114
|
+
.replace( /\/$/, '' );
|
|
115
|
+
|
|
116
|
+
};
|
|
96
117
|
|
|
97
118
|
// Normalize + validate an email address. Trim, lowercase, basic shape
|
|
98
119
|
// check, and reject disposable-domain providers. Returns the normalized
|
|
@@ -171,4 +192,4 @@ const sanitizeQueries = ( req, res, next ) => {
|
|
|
171
192
|
|
|
172
193
|
};
|
|
173
194
|
|
|
174
|
-
export { sanitizeDomain, sanitizeEmail, sanitizeQueries, sanitizeString, sanitizeUrl };
|
|
195
|
+
export { sanitizeDomain, sanitizeEmail, sanitizeHttps, sanitizeQueries, sanitizeString, sanitizeUrl };
|
package/dist/sanitize.js
CHANGED
|
@@ -45,9 +45,13 @@ var sanitizeDomain = (value, pattern) => {
|
|
|
45
45
|
}
|
|
46
46
|
return cleaned;
|
|
47
47
|
};
|
|
48
|
+
var sanitizeHttps = (val) => {
|
|
49
|
+
const value = val == null ? void 0 : val.replace(/^(https?:\/\/)+/i, "");
|
|
50
|
+
return value ? "https://" + value : "";
|
|
51
|
+
};
|
|
48
52
|
var sanitizeUrl = (url) => {
|
|
49
|
-
|
|
50
|
-
return (
|
|
53
|
+
if (!url) return url;
|
|
54
|
+
return sanitizeHttps(url).replace(/^https:\/\/www\./, "https://").replace(/\/$/, "");
|
|
51
55
|
};
|
|
52
56
|
var sanitizeEmail = (raw) => {
|
|
53
57
|
if (typeof raw !== "string") return {
|
|
@@ -89,6 +93,7 @@ var sanitizeQueries = (req, res, next) => {
|
|
|
89
93
|
export {
|
|
90
94
|
sanitizeDomain,
|
|
91
95
|
sanitizeEmail,
|
|
96
|
+
sanitizeHttps,
|
|
92
97
|
sanitizeQueries,
|
|
93
98
|
sanitizeString,
|
|
94
99
|
sanitizeUrl
|
package/package.json
CHANGED