File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -38,5 +38,30 @@ describe("british-english", () => {
3838 "armour-flavouring"
3939 ) ;
4040 } ) ;
41+
42+ it ( "should convert double quotes to single quotes" , async ( ) => {
43+ await expect ( replace ( '"hello"' , "" ) ) . resolves . toEqual ( "'hello'" ) ;
44+ await expect ( replace ( '"test"' , "" ) ) . resolves . toEqual ( "'test'" ) ;
45+ await expect ( replace ( '"Hello World"' , "" ) ) . resolves . toEqual (
46+ "'Hello World'"
47+ ) ;
48+ } ) ;
49+
50+ it ( "should convert double quotes and replace words" , async ( ) => {
51+ await expect ( replace ( '"color"' , "" ) ) . resolves . toEqual ( "'colour'" ) ;
52+ await expect ( replace ( '"math"' , "" ) ) . resolves . toEqual ( "'maths'" ) ;
53+ await expect ( replace ( '"Color"' , "" ) ) . resolves . toEqual ( "'Colour'" ) ;
54+ } ) ;
55+
56+ it ( "should handle multiple double quotes in a word" , async ( ) => {
57+ await expect (
58+ replace ( 'He said "hello" and "goodbye"' , "" )
59+ ) . resolves . toEqual ( "He said 'hello' and 'goodbye'" ) ;
60+ } ) ;
61+
62+ it ( "should not affect words without double quotes" , async ( ) => {
63+ await expect ( replace ( "'hello'" , "" ) ) . resolves . toEqual ( "'hello'" ) ;
64+ await expect ( replace ( "test" , "" ) ) . resolves . toEqual ( "test" ) ;
65+ } ) ;
4166 } ) ;
4267} ) ;
Original file line number Diff line number Diff line change @@ -658,6 +658,11 @@ export async function replace(
658658 word : string ,
659659 previousWord : string
660660) : Promise < string > {
661+ // Convert American-style double quotes to British-style single quotes
662+ if ( word . includes ( '"' ) ) {
663+ word = word . replace ( / " / g, "'" ) ;
664+ }
665+
661666 if ( word . includes ( "-" ) ) {
662667 //this handles hyphenated words (for example "cream-colored") to make sure
663668 //we don't have to add every possible combination to the list
You can’t perform that action at this time.
0 commit comments