@optique/core 1.0.0-dev.1242 → 1.0.0-dev.1244
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/valueparser.cjs +21 -5
- package/dist/valueparser.js +21 -5
- package/package.json +1 -1
package/dist/valueparser.cjs
CHANGED
|
@@ -460,6 +460,19 @@ function float(options = {}) {
|
|
|
460
460
|
};
|
|
461
461
|
}
|
|
462
462
|
/**
|
|
463
|
+
* The set of URL schemes that are considered "special" by the WHATWG URL
|
|
464
|
+
* Standard. These schemes always use the `://` authority syntax.
|
|
465
|
+
* Non-special schemes use only `:` (e.g., `mailto:`, `urn:`).
|
|
466
|
+
*/
|
|
467
|
+
const SPECIAL_URL_SCHEMES = new Set([
|
|
468
|
+
"ftp",
|
|
469
|
+
"file",
|
|
470
|
+
"http",
|
|
471
|
+
"https",
|
|
472
|
+
"ws",
|
|
473
|
+
"wss"
|
|
474
|
+
]);
|
|
475
|
+
/**
|
|
463
476
|
* Creates a {@link ValueParser} for URL values.
|
|
464
477
|
*
|
|
465
478
|
* This parser validates that the input is a well-formed URL and optionally
|
|
@@ -515,12 +528,15 @@ function url(options = {}) {
|
|
|
515
528
|
return value.href;
|
|
516
529
|
},
|
|
517
530
|
*suggest(prefix) {
|
|
518
|
-
if (allowedProtocols && prefix.length > 0 && !prefix.includes("
|
|
531
|
+
if (allowedProtocols && prefix.length > 0 && !prefix.includes(":")) for (const protocol of allowedProtocols) {
|
|
519
532
|
const cleanProtocol = protocol.replace(/:+$/, "");
|
|
520
|
-
if (cleanProtocol.startsWith(prefix.toLowerCase()))
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
533
|
+
if (cleanProtocol.startsWith(prefix.toLowerCase())) {
|
|
534
|
+
const suffix = SPECIAL_URL_SCHEMES.has(cleanProtocol) ? "://" : ":";
|
|
535
|
+
yield {
|
|
536
|
+
kind: "literal",
|
|
537
|
+
text: `${cleanProtocol}${suffix}`
|
|
538
|
+
};
|
|
539
|
+
}
|
|
524
540
|
}
|
|
525
541
|
}
|
|
526
542
|
};
|
package/dist/valueparser.js
CHANGED
|
@@ -460,6 +460,19 @@ function float(options = {}) {
|
|
|
460
460
|
};
|
|
461
461
|
}
|
|
462
462
|
/**
|
|
463
|
+
* The set of URL schemes that are considered "special" by the WHATWG URL
|
|
464
|
+
* Standard. These schemes always use the `://` authority syntax.
|
|
465
|
+
* Non-special schemes use only `:` (e.g., `mailto:`, `urn:`).
|
|
466
|
+
*/
|
|
467
|
+
const SPECIAL_URL_SCHEMES = new Set([
|
|
468
|
+
"ftp",
|
|
469
|
+
"file",
|
|
470
|
+
"http",
|
|
471
|
+
"https",
|
|
472
|
+
"ws",
|
|
473
|
+
"wss"
|
|
474
|
+
]);
|
|
475
|
+
/**
|
|
463
476
|
* Creates a {@link ValueParser} for URL values.
|
|
464
477
|
*
|
|
465
478
|
* This parser validates that the input is a well-formed URL and optionally
|
|
@@ -515,12 +528,15 @@ function url(options = {}) {
|
|
|
515
528
|
return value.href;
|
|
516
529
|
},
|
|
517
530
|
*suggest(prefix) {
|
|
518
|
-
if (allowedProtocols && prefix.length > 0 && !prefix.includes("
|
|
531
|
+
if (allowedProtocols && prefix.length > 0 && !prefix.includes(":")) for (const protocol of allowedProtocols) {
|
|
519
532
|
const cleanProtocol = protocol.replace(/:+$/, "");
|
|
520
|
-
if (cleanProtocol.startsWith(prefix.toLowerCase()))
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
533
|
+
if (cleanProtocol.startsWith(prefix.toLowerCase())) {
|
|
534
|
+
const suffix = SPECIAL_URL_SCHEMES.has(cleanProtocol) ? "://" : ":";
|
|
535
|
+
yield {
|
|
536
|
+
kind: "literal",
|
|
537
|
+
text: `${cleanProtocol}${suffix}`
|
|
538
|
+
};
|
|
539
|
+
}
|
|
524
540
|
}
|
|
525
541
|
}
|
|
526
542
|
};
|