Skip to content

Commit e613878

Browse files
christulinEndBug
andauthored
fix: check if packageFileURL is github host to conditionally send token (#283)
Co-authored-by: Federico Grandi <fgrandi30@gmail.com>
1 parent c68c291 commit e613878

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

lib/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ async function main() {
9595
remote: string = (
9696
await readJson(
9797
packageFileURL,
98-
isPackageFileURLBefore && token ? token : undefined
98+
(isPackageFileURLBefore || isRawGithubUrl(packageFileURL)) && token
99+
? token
100+
: undefined
99101
)
100102
)?.version
101103
if (!local || !remote) {
@@ -146,6 +148,11 @@ function isURL(str: string) {
146148
}
147149
}
148150

151+
function isRawGithubUrl(str: string) {
152+
const url = new URL(str)
153+
return url.hostname === 'raw.githubusercontent.com'
154+
}
155+
149156
async function readJson(file: string, token?: string) {
150157
if (isURL(file)) {
151158
const headers = token

0 commit comments

Comments
 (0)