Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 47c105c

Browse files
committed
fix: double quotes in string not escaped properly #73
close #73
1 parent 910143b commit 47c105c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

‎src/spectra.spec.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ describe('spectra', () => {
66
expect(encodeObject(['foo', 'bar'])).toEqual('(foo bar)');
77
});
88

9+
it('should escape quotes in strings', () => {
10+
expect(encodeObject(['0.96" OLED'])).toEqual('("0.96\\" OLED")');
11+
});
12+
913
it('should ignore null values', () => {
1014
expect(encodeObject(['foo', null, 'bar'])).toEqual('(foo bar)');
1115
});

‎src/spectra.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function encodeString(str: string) {
1010
if (/^[a-z][a-z0-9_]+$/.test(str)) {
1111
return str;
1212
}
13-
return `"${str.replace(/"/g, '""')}"`;
13+
return `"${str.replace(/"/g, '\\"')}"`;
1414
}
1515

1616
function encodeNumber(value: number) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /