Skip to content

Commit

Permalink
Fix crash on Safari (#339)
Browse files Browse the repository at this point in the history
and iOS browsers as they don't support lookbehind is regular expressions.
  • Loading branch information
JosephMarinier committed Dec 16, 2022
1 parent 23a9a70 commit 8c1007e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ Released changes are shown in the
- Showing long utterances fully on hover in similar and perturbed utterances tables.
- Webapp crash when no pipeline.
- Sort confidence or prediction without postprocessing.
- Crash on Safari and iOS browsers as they don't support lookbehind in regular expressions.

### Security
2 changes: 1 addition & 1 deletion webapp/src/utils/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test("formatRatioASPercentageString", () => {
});

describe("camelToTitleCase", () => {
it("should convert CamelCase to TitleCase", () => {
it("should convert CamelCase to Title Case", () => {
expect(camelToTitleCase("SimpleCamelCase")).toBe("Simple Camel Case");
});
it("should support acronyms", () => {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export const formatRatioAsPercentageString = (
) => `${formatNumberAsString(100 * value, digits)}%`;

export const camelToTitleCase = (camelCase: string) =>
camelCase.replace(/(?<=[a-z])(?=[A-Z0-9])|(?<=[A-Z0-9])(?=[A-Z][a-z])/g, " ");
// Safari and iOS browsers don't support lookbehind in regular expressions.
camelCase.replace(/([a-z])(?=[A-Z0-9])|([A-Z0-9])(?=[A-Z][a-z])/g, "$1$2 ");

0 comments on commit 8c1007e

Please sign in to comment.