@ohhwells/bridge 0.1.28 → 0.1.29-next.20
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 +304 -304
- package/dist/index.cjs +19 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -10
- package/dist/index.js.map +1 -1
- package/dist/styles.css +8 -8
- package/package.json +48 -48
package/dist/index.js
CHANGED
|
@@ -4263,7 +4263,10 @@ function isValidUrl(urlString) {
|
|
|
4263
4263
|
const hostname = url.hostname;
|
|
4264
4264
|
if (!hostname || hostname.length === 0) return false;
|
|
4265
4265
|
if (hostname.includes(" ")) return false;
|
|
4266
|
-
|
|
4266
|
+
if (hostname === "localhost") return true;
|
|
4267
|
+
if (!hostname.includes(".")) return false;
|
|
4268
|
+
if (!/[a-z]/i.test(hostname)) return false;
|
|
4269
|
+
return true;
|
|
4267
4270
|
} catch {
|
|
4268
4271
|
return false;
|
|
4269
4272
|
}
|
|
@@ -4274,12 +4277,19 @@ function normalizeUrl(value) {
|
|
|
4274
4277
|
return `https://${trimmed}`;
|
|
4275
4278
|
}
|
|
4276
4279
|
function validateUrlInput(value, pages, allPages) {
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
if (
|
|
4280
|
+
const trimmed = value.trim();
|
|
4281
|
+
if (!trimmed) return "";
|
|
4282
|
+
const exactPage = allPages.find((p) => p.title.toLowerCase() === trimmed.toLowerCase());
|
|
4283
|
+
if (exactPage) return "";
|
|
4284
|
+
const hasPrefixMatch = pages.some((p) => p.title.toLowerCase().startsWith(trimmed.toLowerCase()));
|
|
4285
|
+
if (hasPrefixMatch) {
|
|
4286
|
+
return "Select a page from the list or enter a valid URL";
|
|
4287
|
+
}
|
|
4288
|
+
const hasScheme = /^https?:\/\//i.test(trimmed);
|
|
4289
|
+
if (!hasScheme && !trimmed.includes(".")) {
|
|
4290
|
+
return "Please enter a valid URL (e.g., https://example.com)";
|
|
4291
|
+
}
|
|
4292
|
+
if (!isValidUrl(normalizeUrl(trimmed))) {
|
|
4283
4293
|
return "Please enter a valid URL (e.g., https://example.com)";
|
|
4284
4294
|
}
|
|
4285
4295
|
return "";
|
|
@@ -4822,9 +4832,8 @@ function useLinkModalState({
|
|
|
4822
4832
|
setUrlError("");
|
|
4823
4833
|
const filtered = value.trim() ? availablePages.filter((p) => p.title.toLowerCase().startsWith(value.toLowerCase())) : availablePages;
|
|
4824
4834
|
setDropdownOpen(filtered.length > 0);
|
|
4825
|
-
if (value.trim()
|
|
4826
|
-
|
|
4827
|
-
if (error) setUrlError(error);
|
|
4835
|
+
if (value.trim()) {
|
|
4836
|
+
setUrlError(validateUrlInput(value, availablePages, pages));
|
|
4828
4837
|
}
|
|
4829
4838
|
};
|
|
4830
4839
|
const handlePageSelect = (page) => {
|