Skip to content

Commit

Permalink
Fix URL validation by preserving percent-encoded characters (#9326)
Browse files Browse the repository at this point in the history
  • Loading branch information
kidneyweakx authored Sep 24, 2024
1 parent 2cd1fa2 commit 8cb70c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/old-dolphins-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@keystone-6/fields-document": patch
---

Fixes URL validation bug by using `encodeURI` to preserve percent-encoded characters during validation.
2 changes: 1 addition & 1 deletion packages/fields-document/src/DocumentEditor/isValidURL.ts
Original file line number Diff line number Diff line change
@@ -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))
}

0 comments on commit 8cb70c9

Please sign in to comment.