Skip to content

Commit

Permalink
Support Embed and ResourceParam
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki777 committed May 17, 2024
1 parent d32b74c commit d6a2ff2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/PeekFileDefinitionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class PeekFileDefinitionProvider implements vscode.DefinitionProv
resourceAppPaths: string[] = [];
resourcePagePaths: string[] = [];

public static readonly regexPattern = /(get|post|put|delete|resource|uri)\(['"](app|page):\/\/self\/(.*)['"]/;
public static readonly regexPattern = /(get|post|put|delete|resource|uri|ResourceParam|Embed)\(.*?(app|page):\/\/self\/(.*)['"]/;

constructor(targetFileExtensions: string[] = [], resourceAppPaths: string[] = [], resourcePagePaths: string[] = []) {
this.targetFileExtensions = targetFileExtensions;
Expand Down
5 changes: 4 additions & 1 deletion src/test/regexTest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @see PeekFileDefinitionProvider.regexPattern
const regexPattern = /(get|post|put|delete|resource|uri)\(['"](app|page):\/\/self\/(.*)['"]/;
const regexPattern = /(get|post|put|delete|resource|uri|ResourceParam|Embed)\(.*?(app|page):\/\/self\/(.*)['"]/;

function testRegexTrue(target) {
// Test
Expand Down Expand Up @@ -34,6 +34,9 @@ testRegexTrue("put('app://self/foo')");
testRegexTrue("delete('app://self/foo')");
testRegexTrue('resource("app://self/foo")');
testRegexTrue('uri("app://self/foo")');
testRegexTrue("#[ResourceParam(uri: 'app://self/user#ulid', param: 'userId')]");
testRegexTrue("#[Embed(rel: 'foo', src: 'app://self/foo{?ulid}')]");

testRegexFalse('resource("foo://self/foo")');
testRegexFalse('foo("app://self/foo")');
testRegexFalse('getFoo("app://self/foo")');

0 comments on commit d6a2ff2

Please sign in to comment.