Skip to content

Commit

Permalink
fix: be more liberal with spaces in module expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Yogu committed Sep 12, 2024
1 parent 51a84d9 commit 412da2f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
44 changes: 44 additions & 0 deletions spec/schema/ast-validation-modules/modules-validator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,50 @@ describe('modules validator', () => {
);
});

it('accepts an expression that starts with spaces', () => {
assertValidatorAcceptsAndDoesNotWarn(
`
type Foo @rootEntity @modules(in: [" module1"]) {
foo: String @modules(all: true)
}
`,
{ withModuleDefinitions: true },
);
});

it('accepts an expression that ends in a tab', () => {
assertValidatorAcceptsAndDoesNotWarn(
`
type Foo @rootEntity @modules(in: ["module1 & module2\t"]) {
foo: String @modules(all: true)
}
`,
{ withModuleDefinitions: true },
);
});

it('accepts an expression that ends in a space', () => {
assertValidatorAcceptsAndDoesNotWarn(
`
type Foo @rootEntity @modules(in: ["module1 & module2 "]) {
foo: String @modules(all: true)
}
`,
{ withModuleDefinitions: true },
);
});

it('accepts an and combination of two modules with multiple space characters', () => {
assertValidatorAcceptsAndDoesNotWarn(
`
type Foo @rootEntity @modules(in: ["module1 &\tmodule2"]) {
foo: String @modules(all: true)
}
`,
{ withModuleDefinitions: true },
);
});

it('accepts an and combination of three modules', () => {
assertValidatorAcceptsAndDoesNotWarn(
`
Expand Down
2 changes: 1 addition & 1 deletion src/model/implementation/modules/expression-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function parseModuleSpecificationExpression(
if (char === '&') {
// expecting next module
state = ParserState.EXPECT_IDENTIFIER;
} else if (isEOF) {
} else if (isEOF || isWhitespace) {
// do nothing
} else {
return {
Expand Down

0 comments on commit 412da2f

Please sign in to comment.