Fix StringUtils.ensureQuoted to escape multiple quotations (#382)
This commit is contained in:
Родитель
a92d1f0016
Коммит
6a2dcc8600
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@microsoft/powerquery-parser",
|
||||
"version": "0.15.8",
|
||||
"version": "0.15.10",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@microsoft/powerquery-parser",
|
||||
"version": "0.15.8",
|
||||
"version": "0.15.10",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"grapheme-splitter": "^1.0.4",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@microsoft/powerquery-parser",
|
||||
"version": "0.15.9",
|
||||
"version": "0.15.10",
|
||||
"description": "A parser for the Power Query/M formula language.",
|
||||
"author": "Microsoft",
|
||||
"license": "MIT",
|
||||
|
|
|
@ -45,7 +45,7 @@ export function ensureQuoted(text: string): string {
|
|||
return text;
|
||||
}
|
||||
|
||||
return `"${text.includes(`"`) ? text.replace(`"`, `""`) : text}"`;
|
||||
return `"${text.replace(/"/g, '""')}"`;
|
||||
}
|
||||
|
||||
export function columnNumberFrom(text: string, requiredCodeUnit: number): number {
|
||||
|
|
|
@ -13,6 +13,7 @@ describe("StringUtils", () => {
|
|||
it(`"`, () => expect(StringUtils.ensureQuoted(`"`)).to.equal(`""""`));
|
||||
it(`""`, () => expect(StringUtils.ensureQuoted(`""`)).to.equal(`""`));
|
||||
it(`"a"`, () => expect(StringUtils.ensureQuoted(`"a"`)).to.equal(`"a"`));
|
||||
it(`a"b"c`, () => expect(StringUtils.ensureQuoted(`a"b"c`)).to.equal(`"a""b""c"`));
|
||||
});
|
||||
|
||||
describe(`findQuote`, () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче