diff --git a/src/regexes.ts b/src/regexes.ts index 126f62f..134f355 100644 --- a/src/regexes.ts +++ b/src/regexes.ts @@ -12,7 +12,7 @@ export const edgeComponentsAsTagsRegex = /** * Find all the views that are being used inside a TS/Js file */ -export const tsRegex = /((?:[Vv]iew|[Ee]dge)\.render(?:Sync)?\(['"](.*)['"])/g +export const tsRegex = /((?:[Vv]iew|[Ee]dge)\.render(?:Sync)?\(['"](.*?)['"])/g /** * Check if we are currently inside a view link and capture the user input to suggest completions diff --git a/tests/linker.spec.ts b/tests/linker.spec.ts index 60507ec..1483ff2 100644 --- a/tests/linker.spec.ts +++ b/tests/linker.spec.ts @@ -418,4 +418,31 @@ test.group('Views Linker | .ts', () => { const positions = result.map((r) => r.position) assert.deepEqual(positions, [{ colEnd: 37, colStart: 20, line: 2 }]) }) + + test('should find link even when the template props include "(" character', async ({ + assert, + fs, + }) => { + await fs.create('resources/views/components/button.edge', '') + + const template = dedent` + return view.render('components/button', { prop: route('bar') }) + ` + + const indexer = new TemplateIndexer({ + rootPath: fs.basePath, + disks: { default: 'resources/views' }, + }) + + await indexer.scan() + + const result = await Linker.getLinks({ + fileContent: template, + indexer, + sourceType: 'ts', + }) + + const positions = result.map((r) => r.position) + assert.deepEqual(positions, [{ colEnd: 37, colStart: 20, line: 0 }]) + }) })