API reference › @evolu/common › Type › UrlSafeString
const UrlSafeString: regex(
"UrlSafeString",
/^[A-Za-z0-9_-]+$/,
)(String);
Defined in: packages/common/src/Type.ts:1554
URL-safe string.
A UrlSafeString uses a limited alphabet that is safe for URLs:
- Uppercase letters (
A-Z) - Lowercase letters (
a-z) - Digits (
0-9) - Dash (
-) - Underscore (
_)
This is the same character set used by Base64Url encoding, but this type does not validate that the string is actually Base64Url-encoded data.
Example
const result = UrlSafeString.from("abc123_-");
if (result.ok) {
console.log("Valid URL-safe string:", result.value);
} else {
console.error("Invalid URL-safe string:", result.error);
}