diff --git a/.changeset/old-dolphins-obey.md b/.changeset/old-dolphins-obey.md new file mode 100644 index 00000000000..14bbfd82cf6 --- /dev/null +++ b/.changeset/old-dolphins-obey.md @@ -0,0 +1,5 @@ +--- +"@keystone-6/fields-document": patch +--- + +Fixes URL validation bug by using `encodeURI` to preserve percent-encoded characters during validation. diff --git a/packages/fields-document/src/DocumentEditor/isValidURL.ts b/packages/fields-document/src/DocumentEditor/isValidURL.ts index 3eb425ff1e5..8087fc7fc66 100644 --- a/packages/fields-document/src/DocumentEditor/isValidURL.ts +++ b/packages/fields-document/src/DocumentEditor/isValidURL.ts @@ -1,5 +1,5 @@ import { sanitizeUrl } from '@braintree/sanitize-url' export function isValidURL (url: string) { - return url === sanitizeUrl(url) + return url === sanitizeUrl(url) || url === encodeURI(sanitizeUrl(url)) }