Skip to content

Commit

Permalink
Merge pull request #31 from bee-browser/master
Browse files Browse the repository at this point in the history
Support branch names
  • Loading branch information
hayd authored Apr 23, 2021
2 parents e587c98 + b97aeca commit 8a5dd73
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ export class Udd {
url.url = `${url.at(initVersion.slice(1)).url}#${newFragmentToken}`;
}

try {
new Semver(url.version());
} catch (e) {
// The version string is a non-semver string like a branch name.
await this.progress.log(`Skip updating: ${url.url}`);
return { initUrl, initVersion };
}

// if we pass a fragment with semver
let filter: ((other: Semver) => boolean) | undefined = undefined;
try {
Expand Down
13 changes: 13 additions & 0 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,16 @@ Deno.test("uddFakeregistryFragmentMoveEq", async () => {
const expected = 'import "https://fakeregistry.com/foo@0.0.1/mod.ts#=";';
await testUdd(contents, expected);
});

Deno.test("uddGitHubRawBranchName", async () => {
const contents = `
import "https://raw.githubusercontent.com/foo/bar/main/mod.ts";
import "https://raw.githubusercontent.com/foo/bar/main/mod.ts#=";
`;
const expected = `
import "https://raw.githubusercontent.com/foo/bar/main/mod.ts";
import "https://raw.githubusercontent.com/foo/bar/main/mod.ts#=";
`;
const results = await testUdd(contents, expected);
assertEquals(results.length, 0);
});

0 comments on commit 8a5dd73

Please sign in to comment.