Skip to content

Commit

Permalink
fix: Trim URLs to avoid sanitation errors (#3286)
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr authored Jun 18, 2024
1 parent 604cd37 commit 1b59cca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion editor.planx.uk/src/ui/editor/RichTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,12 @@ const initialUrlValue = "https://";

// Makes sure that if the user pastes a full URL into the input, the pre-populated `https://` is removed
// e.g. https://https://something.com -> https://something.com
// Also trim whitespace from links which flag sanitation errors
const trimUrlValue = (url: string) => {
if (url.startsWith(`${initialUrlValue}${initialUrlValue}`)) {
return url.slice(initialUrlValue.length);
}
return url;
return url.trim();
};

const getContentHierarchyError = (doc: JSONContent): string | null => {
Expand Down

0 comments on commit 1b59cca

Please sign in to comment.