@drawbridge/drawbridge-utils 0.0.73 → 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 CHANGED
@@ -88,8 +88,8 @@ var sanitizeHttps = (val) => {
88
88
  return value ? "https://" + value : "";
89
89
  };
90
90
  var sanitizeUrl = (url) => {
91
- var _a, _b;
92
- return (_b = (_a = url == null ? void 0 : url.replace(/^http:\/\//, "https://")) == null ? void 0 : _a.replace(/^https:\/\/www\./, "https://")) == null ? void 0 : _b.replace(/\/$/, "");
91
+ if (!url) return url;
92
+ return sanitizeHttps(url).replace(/^https:\/\/www\./, "https://").replace(/\/$/, "");
93
93
  };
94
94
  var sanitizeEmail = (raw) => {
95
95
  if (typeof raw !== "string") return {
@@ -101,10 +101,19 @@ const sanitizeHttps = ( val ) => {
101
101
 
102
102
  };
103
103
 
104
- const sanitizeUrl = ( url ) => url
105
- ?.replace( /^http:\/\//, 'https://' )
106
- ?.replace( /^https:\/\/www\./, 'https://' )
107
- ?.replace( /\/$/, '' );
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
+ };
108
117
 
109
118
  // Normalize + validate an email address. Trim, lowercase, basic shape
110
119
  // check, and reject disposable-domain providers. Returns the normalized
@@ -101,10 +101,19 @@ const sanitizeHttps = ( val ) => {
101
101
 
102
102
  };
103
103
 
104
- const sanitizeUrl = ( url ) => url
105
- ?.replace( /^http:\/\//, 'https://' )
106
- ?.replace( /^https:\/\/www\./, 'https://' )
107
- ?.replace( /\/$/, '' );
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
+ };
108
117
 
109
118
  // Normalize + validate an email address. Trim, lowercase, basic shape
110
119
  // check, and reject disposable-domain providers. Returns the normalized
package/dist/sanitize.js CHANGED
@@ -50,8 +50,8 @@ var sanitizeHttps = (val) => {
50
50
  return value ? "https://" + value : "";
51
51
  };
52
52
  var sanitizeUrl = (url) => {
53
- var _a, _b;
54
- return (_b = (_a = url == null ? void 0 : url.replace(/^http:\/\//, "https://")) == null ? void 0 : _a.replace(/^https:\/\/www\./, "https://")) == null ? void 0 : _b.replace(/\/$/, "");
53
+ if (!url) return url;
54
+ return sanitizeHttps(url).replace(/^https:\/\/www\./, "https://").replace(/\/$/, "");
55
55
  };
56
56
  var sanitizeEmail = (raw) => {
57
57
  if (typeof raw !== "string") return {
package/package.json CHANGED
@@ -158,5 +158,5 @@
158
158
  "build": "tsup && npm publish"
159
159
  },
160
160
  "types": "dist/index.d.ts",
161
- "version": "0.0.73"
161
+ "version": "0.0.74"
162
162
  }