Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected constructor(protected readonly options: GithubOptions, defaultHost: string, runtimeOptions: ProviderRuntimeOptions) {
super({
...runtimeOptions,
/* because GitHib uses S3 */
isUseMultipleRangeRequest: false,
})
this.baseUrl = newBaseUrl(githubUrl(options, defaultHost))
const apiHost = defaultHost === "github.com" ? "api.github.com" : defaultHost
this.baseApiUrl = newBaseUrl(githubUrl(options, apiHost))
}
protected constructor(protected readonly options: GithubOptions, defaultHost: string, runtimeOptions: ProviderRuntimeOptions) {
super({
...runtimeOptions,
/* because GitHib uses S3 */
isUseMultipleRangeRequest: false,
})
this.baseUrl = newBaseUrl(githubUrl(options, defaultHost))
const apiHost = defaultHost === "github.com" ? "api.github.com" : defaultHost
this.baseApiUrl = newBaseUrl(githubUrl(options, apiHost))
}
export function computeDownloadUrl(publishConfiguration: PublishConfiguration, fileName: string | null, packager: PlatformPackager) {
if (publishConfiguration.provider === "generic") {
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)}`
}