Mirror: The spec-compliant minimum of client-side GraphQL.

fix: Fix typo causing complex string parsing to fail on subsequent runs (#31)

* Fix typo in complex string detection

Fix typo causing complex string detection not to trigger
correctly.

* Add changeset

* Add test

Changed files
+23 -1
.changeset
src
+5
.changeset/two-days-nail.md
···
+
---
+
'@0no-co/graphql.web': patch
+
---
+
+
Fix typo causing complex string parsing to fail on subsequent runs.
+17
src/__tests__/parser.test.ts
···
}).toThrow();
});
+
it('parses escaped characters', () => {
+
let ast = parse(`
+
{ field(arg: "Has another \\\\x sequence.") }
+
`);
+
expect(ast).toHaveProperty(
+
'definitions.0.selectionSet.selections.0.arguments.0.value.value',
+
'Has another \\x sequence.'
+
);
+
ast = parse(`
+
{ field(arg: "Has a \\\\x sequence.") }
+
`);
+
expect(ast).toHaveProperty(
+
'definitions.0.selectionSet.selections.0.arguments.0.value.value',
+
'Has a \\x sequence.'
+
);
+
});
+
it('parses multi-byte characters', () => {
// Note: \u0A0A could be naively interpreted as two line-feed chars.
const ast = parse(`
+1 -1
src/parser.ts
···
[Prop in ValueGroup]: string | undefined;
};
-
const complexStringRe = /\\/g;
+
const complexStringRe = /\\/;
function value(constant: true): ast.ConstValueNode;
function value(constant: boolean): ast.ValueNode;