Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send token in readJson if using raw github url as file-url #283

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ async function main() {
remote: string = (
await readJson(
packageFileURL,
isPackageFileURLBefore && token ? token : undefined
(isPackageFileURLBefore || isRawGithubUrl(packageFileURL)) && token
? token
: undefined
)
)?.version
if (!local || !remote) {
Expand Down Expand Up @@ -146,6 +148,11 @@ function isURL(str: string) {
}
}

function isRawGithubUrl(str: string) {
const url = new URL(str)
return url.hostname === 'raw.githubusercontent.com'
}

async function readJson(file: string, token?: string) {
if (isURL(file)) {
const headers = token
Expand Down