Skip to content

Commit

Permalink
fix: universal match
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Mar 10, 2024
1 parent 8e1959a commit 51add2a
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,39 +91,32 @@ export const RELEASE_RULE: ReleaseRuleItem[] = [
output: "v7.20.0",
}],
},
// Universal Match
{
matchVersion: (url: string) => {
return url.match(
/https:\/\/.+\/.*?v(?<version>[\d.]+)/,
/https:\/\/.+\/.*?v(?<version>[\d.-]+)/,
);
},
version: ({ match }) => `v${match?.groups?.version}`,
version: ({ match }) => {
// if - is included, it should be replaced with .
return `v${match?.groups?.version.replaceAll("-", ".")}`;
},
tests: [{
input: "https://deno.com/blog/v1.19",
output: "v1.19",
}, {
input: "https://bun.sh/blog/bun-v0.6.8",
output: "v0.6.8",
},{
input: "https://deno.com/blog/fastest-git-deploys-to-the-edge",
output: undefined,
}],
},
{
matchVersion: (url: string) => {
return url.match(
/https:\/\/.+\/.*?v(?<version>[\d.-]+)/,
);
},
version: ({ match }) => {
return `v${match?.groups?.version?.replaceAll("-", ".")}`;
},
tests: [{
}, {
input: "https://biomejs.dev/blog/biome-v1-6/",
output: "v1.6",
},{
}, {
input: "https://example.com/voooo1-6",
output: undefined,
}, {
input: "https://deno.com/blog/fastest-git-deploys-to-the-edge",
output: undefined,
}],
},
];
Expand Down

0 comments on commit 51add2a

Please sign in to comment.