Skip to content

Commit

Permalink
remove santitize string function
Browse files Browse the repository at this point in the history
  • Loading branch information
esizer committed Dec 19, 2024
1 parent 1324206 commit 0905484
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 17 deletions.
2 changes: 0 additions & 2 deletions packages/forms/src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import useFieldState from "../../hooks/useFieldState";
import useFieldStateStyles from "../../hooks/useFieldStateStyles";
import useInputDescribedBy from "../../hooks/useInputDescribedBy";
import useInputStyles from "../../hooks/useInputStyles";
import { sanitizeString } from "../../utils";

export type InputProps = HTMLInputProps &
CommonInputProps & {
Expand Down Expand Up @@ -61,7 +60,6 @@ const Input = ({
if (whitespaceTrim) {
inputValue = inputValue.trim();
}
inputValue = sanitizeString(inputValue);
setValue(name, inputValue);
};

Expand Down
3 changes: 1 addition & 2 deletions packages/forms/src/components/TextArea/TextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { errorMessages } from "@gc-digital-talent/i18n";
import Field from "../Field";
import WordCounter from "../WordCounter";
import type { CommonInputProps } from "../../types";
import { countNumberOfWords, sanitizeString } from "../../utils";
import { countNumberOfWords } from "../../utils";
import useFieldState from "../../hooks/useFieldState";
import useFieldStateStyles from "../../hooks/useFieldStateStyles";
import useInputDescribedBy from "../../hooks/useInputDescribedBy";
Expand Down Expand Up @@ -65,7 +65,6 @@ const TextArea = ({
if (whitespaceTrim) {
inputValue = inputValue.trim();
}
inputValue = sanitizeString(inputValue);
setValue(name, inputValue);
};

Expand Down
13 changes: 0 additions & 13 deletions packages/forms/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,6 @@ export function htmlToRichTextJSON(html: string): Node {
return generateJSON(html, [StarterKit, Link]) as Node;
}

const sanitizeSubstitutions: Record<string, string> = {
"\u202F": "\u00A0", // Narrow No-Break Space ➡️ No-Break Space
} as const;

export function sanitizeString(original: string): string {
let str = original;
Object.keys(sanitizeSubstitutions).forEach((key) => {
const replacement = sanitizeSubstitutions[key];
str = str.replace(new RegExp(key, "g"), replacement);
});
return str;
}

/**
* Flatten Errors
*
Expand Down

0 comments on commit 0905484

Please sign in to comment.