Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
switch (provider) {
case "github":
const githubOptions = data as GithubOptions
const token = (githubOptions.private ? process.env.GH_TOKEN || process.env.GITHUB_TOKEN : null) || githubOptions.token
if (token == null) {
return new GitHubProvider(githubOptions, updater, runtimeOptions)
}
else {
return new PrivateGitHubProvider(githubOptions, updater, token, runtimeOptions)
}
case "s3":
case "spaces":
return new GenericProvider({
provider: "generic",
url: getS3LikeProviderBaseUrl(data),
channel: (data as BaseS3Options).channel || null
}, updater, {
...runtimeOptions,
// https://github.com/minio/minio/issues/5285#issuecomment-350428955
isUseMultipleRangeRequest: provider === "spaces",
})
case "generic":
const options = data as GenericServerOptions
return new GenericProvider(options, updater, {
...runtimeOptions,
isUseMultipleRangeRequest: options.useMultipleRangeRequest !== false && isUrlProbablySupportMultiRangeRequests(options.url),
})
case "bintray":
return new BintrayProvider(data as BintrayOptions, runtimeOptions)
const baseUrlString = (publishConfiguration as GenericServerOptions).url
if (fileName == null) {
return baseUrlString
}
const baseUrl = url.parse(baseUrlString)
return url.format({...baseUrl as url.UrlObject, pathname: path.posix.resolve(baseUrl.pathname || "/", encodeURI(fileName))})
}
let baseUrl
if (publishConfiguration.provider === "github") {
const gh = publishConfiguration as GithubOptions
baseUrl = `${githubUrl(gh)}/${gh.owner}/${gh.repo}/releases/download/${gh.vPrefixedTagName === false ? "" : "v"}${packager.appInfo.version}`
}
else {
baseUrl = getS3LikeProviderBaseUrl(publishConfiguration)
}
if (fileName == null) {
return baseUrl
}
return `${baseUrl}/${encodeURI(fileName)}`
}