kurtosis-ui-components 0.87.2 → 0.87.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function parsePackageUrl(packageUrl) {
|
|
2
2
|
const components = packageUrl
|
|
3
3
|
.replace(/https?:\/\//, "")
|
|
4
|
-
.replace(/(?<=github\.com\/
|
|
4
|
+
.replace(/(?<=github\.com\/[^/]+\/[^/]+)\/tree\/([^/]+)/, "")
|
|
5
5
|
.split("/");
|
|
6
6
|
if (components.length < 3) {
|
|
7
7
|
throw Error(`Illegal url, invalid number of components: ${packageUrl}`);
|
|
@@ -9,10 +9,13 @@ export function parsePackageUrl(packageUrl) {
|
|
|
9
9
|
if (components[1].length < 1 || components[2].length < 1) {
|
|
10
10
|
throw Error(`Illegal url, empty components: ${packageUrl}`);
|
|
11
11
|
}
|
|
12
|
+
const branchMatches = packageUrl.match(/(?<=github\.com\/[^/]+\/[^/]+)\/tree\/([^/]+)/);
|
|
13
|
+
const defaultBranch = branchMatches ? branchMatches[1] : undefined;
|
|
12
14
|
return {
|
|
13
15
|
baseUrl: "github.com",
|
|
14
16
|
owner: components[1],
|
|
15
17
|
name: components[2],
|
|
16
18
|
rootPath: components.filter((v, i) => i > 2 && v.length > 0).join("/") + "/",
|
|
19
|
+
defaultBranch,
|
|
17
20
|
};
|
|
18
21
|
}
|