diff --git a/src/__tests__/url-encode.spec.ts b/src/__tests__/url-encode.spec.ts index 22272ddd..384f3bcc 100644 --- a/src/__tests__/url-encode.spec.ts +++ b/src/__tests__/url-encode.spec.ts @@ -134,6 +134,15 @@ describe('URL encoder', () => { const expected = ['3/2', 'foo', 'BAR', '2/1'] expect(arraysEqual(decodeLines('3F2_EfEoEo_EBAER_2F1'), expected)).toBeTruthy() }) + + it('can encode repeated L characters in invalid lines', () => { + const lines = ['sLL', '9/8', '3/2', '2/1'] + expect(encodeLines(lines)).toBe('EsELEL_9F8_3F2_2F1') + }) + + it('can decode repeated L characters in invalid lines', () => { + expect(decodeLines('EsELEL_9F8_3F2_2F1')).toEqual(['sLL', '9/8', '3/2', '2/1']) + }) }) describe('URL decoder', () => { diff --git a/src/url-encode.ts b/src/url-encode.ts index fbc51876..aee71047 100644 --- a/src/url-encode.ts +++ b/src/url-encode.ts @@ -80,15 +80,15 @@ function decodeDigits(digits: string) { function encodeLine(scaleLine: string) { scaleLine = scaleLine - .replace(ESCAPE, ESCAPE + ESCAPE) - .replace(FRACTION, ESCAPE + FRACTION) - .replace(COMMA, ESCAPE + COMMA) - .replace(BACKSLASH, ESCAPE + BACKSLASH) - .replace(SPACE, ESCAPE + SPACE) - .replace(LEFT_ANGLE_BRACKET, ESCAPE + LEFT_ANGLE_BRACKET) - .replace(RIGHT_ANGLE_BRACKET, ESCAPE + RIGHT_ANGLE_BRACKET) - .replace(LEFT_SQUARE_BRACKET, ESCAPE + LEFT_SQUARE_BRACKET) - .replace(PLUS, ESCAPE + PLUS) + .replaceAll(ESCAPE, ESCAPE + ESCAPE) + .replaceAll(FRACTION, ESCAPE + FRACTION) + .replaceAll(COMMA, ESCAPE + COMMA) + .replaceAll(BACKSLASH, ESCAPE + BACKSLASH) + .replaceAll(SPACE, ESCAPE + SPACE) + .replaceAll(LEFT_ANGLE_BRACKET, ESCAPE + LEFT_ANGLE_BRACKET) + .replaceAll(RIGHT_ANGLE_BRACKET, ESCAPE + RIGHT_ANGLE_BRACKET) + .replaceAll(LEFT_SQUARE_BRACKET, ESCAPE + LEFT_SQUARE_BRACKET) + .replaceAll(PLUS, ESCAPE + PLUS) scaleLine = scaleLine .replace(/\//g, FRACTION) diff --git a/tsconfig.app.json b/tsconfig.app.json index 3b26808e..5376aaef 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -8,6 +8,7 @@ "baseUrl": ".", "paths": { "@/*": ["./src/*"] - } + }, + "lib": ["es2021"] } } diff --git a/tsconfig.node.json b/tsconfig.node.json index dee96bed..8b65c67f 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -11,6 +11,7 @@ "composite": true, "module": "ESNext", "moduleResolution": "Bundler", - "types": ["node"] + "types": ["node"], + "lib": ["es2021"] } } diff --git a/tsconfig.vitest.json b/tsconfig.vitest.json index d5757a62..cf2377fe 100644 --- a/tsconfig.vitest.json +++ b/tsconfig.vitest.json @@ -4,7 +4,6 @@ "exclude": [], "compilerOptions": { "composite": true, - "lib": [], "types": ["node", "jsdom"] } }