Skip to content

Commit b9c44b4

Browse files
committed
fix: improve URL validation for GitHub API detection
1 parent cc4886d commit b9c44b4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,11 @@ jobs:
109109
with:
110110
node-version: "18"
111111
registry-url: "https://registry.npmjs.org"
112+
- name: Force registry for scoped npm package
113+
run: echo "@eggl-js:registry=https://registry.npmjs.org/" >> ~/.npmrc
112114

113115
- name: Publish to npmjs.org
114-
run: npm publish
116+
run: npm publish --access public
115117
env:
116118
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
117119

@@ -137,6 +139,7 @@ jobs:
137139
with:
138140
node-version: "18"
139141
registry-url: "https://npm.pkg.github.com"
142+
scope: "@robert27"
140143

141144
- name: Set scope for GitHub Packages
142145
run: |

src/download.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ async function downloadFileAsync(
3232
try {
3333
logger.info(`Downloading from URL: ${url}`);
3434

35-
const isGitHubApiUrl = url.includes("api.github.com");
35+
let isGitHubApiUrl = false;
36+
try {
37+
const parsedUrl = new URL(url);
38+
isGitHubApiUrl = parsedUrl.hostname === "api.github.com";
39+
} catch {
40+
// Invalid URL format, treat as non-GitHub
41+
isGitHubApiUrl = false;
42+
}
3643

3744
const headers: Record<string, string> = {
3845
Accept: "application/octet-stream",

0 commit comments

Comments
 (0)