mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-05 06:54:36 +08:00
impr(british english): replace double quotes with single quotes
closes #7015
This commit is contained in:
parent
be106b8f1c
commit
015252120f
2 changed files with 30 additions and 0 deletions
|
|
@ -38,5 +38,30 @@ describe("british-english", () => {
|
|||
"armour-flavouring"
|
||||
);
|
||||
});
|
||||
|
||||
it("should convert double quotes to single quotes", async () => {
|
||||
await expect(replace('"hello"', "")).resolves.toEqual("'hello'");
|
||||
await expect(replace('"test"', "")).resolves.toEqual("'test'");
|
||||
await expect(replace('"Hello World"', "")).resolves.toEqual(
|
||||
"'Hello World'"
|
||||
);
|
||||
});
|
||||
|
||||
it("should convert double quotes and replace words", async () => {
|
||||
await expect(replace('"color"', "")).resolves.toEqual("'colour'");
|
||||
await expect(replace('"math"', "")).resolves.toEqual("'maths'");
|
||||
await expect(replace('"Color"', "")).resolves.toEqual("'Colour'");
|
||||
});
|
||||
|
||||
it("should handle multiple double quotes in a word", async () => {
|
||||
await expect(
|
||||
replace('He said "hello" and "goodbye"', "")
|
||||
).resolves.toEqual("He said 'hello' and 'goodbye'");
|
||||
});
|
||||
|
||||
it("should not affect words without double quotes", async () => {
|
||||
await expect(replace("'hello'", "")).resolves.toEqual("'hello'");
|
||||
await expect(replace("test", "")).resolves.toEqual("test");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -658,6 +658,11 @@ export async function replace(
|
|||
word: string,
|
||||
previousWord: string
|
||||
): Promise<string> {
|
||||
// Convert American-style double quotes to British-style single quotes
|
||||
if (word.includes('"')) {
|
||||
word = word.replace(/"/g, "'");
|
||||
}
|
||||
|
||||
if (word.includes("-")) {
|
||||
//this handles hyphenated words (for example "cream-colored") to make sure
|
||||
//we don't have to add every possible combination to the list
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue