Skip to content

Commit 30361a8

Browse files
Support dots in URL path segments (#7)
Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 2c8de7b commit 30361a8

File tree

6 files changed

+27
-3
lines changed

6 files changed

+27
-3
lines changed

.changeset/brave-ads-leave.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"urlspec-vscode-extension": patch
3+
"@urlspec/language": patch
4+
---
5+
6+
fix: support `.` in path

packages/language/src/__generated__/ast.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/language/src/__generated__/grammar.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/language/src/urlspec.langium

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ hidden terminal SL_COMMENT:
4545
/\/\/[^\n\r]*/;
4646

4747
terminal PATH_SEGMENT:
48-
/\/[a-zA-Z0-9_-]+/;
48+
/\/[a-zA-Z0-9_.\-]+/;
4949

5050
terminal PARAM_PREFIX:
5151
'/:';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Lynx Native Modules 테스트 문서 페이지
2+
page docs = /main.lynx.bundle {}
3+
4+
page apiV1 = /api/v1.0/users {}
5+
6+
page bundleFile = /assets/app.min.js {}

packages/language/test/parser.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ describe("URLSpec Parser", () => {
7373
expect(model.pages).toHaveLength(2);
7474
});
7575

76+
it("should parse paths with dots", async () => {
77+
const doc = await parseFile(fixture("dot-in-path.urlspec"));
78+
expect(doc.parseResult.lexerErrors).toHaveLength(0);
79+
expect(doc.parseResult.parserErrors).toHaveLength(0);
80+
81+
const model = doc.parseResult.value;
82+
expect(model.pages).toHaveLength(3);
83+
expect(model.pages[0]?.path.segments[0]?.static).toBe("/main.lynx.bundle");
84+
expect(model.pages[1]?.path.segments[1]?.static).toBe("/v1.0");
85+
expect(model.pages[2]?.path.segments[1]?.static).toBe("/app.min.js");
86+
});
87+
7688
it("should parse spec with comments", async () => {
7789
const doc = await parseFile(fixture("with-comments.urlspec"));
7890
expect(doc.parseResult.lexerErrors).toHaveLength(0);

0 commit comments

Comments
 (0)