mirror of
https://code.forgejo.org/actions/checkout.git
synced 2025-04-24 04:15:33 +00:00
fix: support pathname except ssh
This commit is contained in:
parent
b4ffde65f4
commit
61d93be5e5
5 changed files with 27 additions and 12 deletions
|
@ -53,7 +53,8 @@ class GitAuthHelper {
|
|||
|
||||
// Token auth header
|
||||
const serverUrl = urlHelper.getServerUrl(this.settings.githubServerUrl)
|
||||
this.tokenConfigKey = `http.${serverUrl.origin}/.extraheader` // "origin" is SCHEME://HOSTNAME[:PORT]
|
||||
const baseURL = urlHelper.getBaseUrl(serverUrl.href)
|
||||
this.tokenConfigKey = `http.${baseURL}/.extraheader` // "origin" is SCHEME://HOSTNAME[:PORT]
|
||||
const basicCredential = Buffer.from(
|
||||
`x-access-token:${this.settings.authToken}`,
|
||||
'utf8'
|
||||
|
@ -63,7 +64,7 @@ class GitAuthHelper {
|
|||
this.tokenConfigValue = `AUTHORIZATION: basic ${basicCredential}`
|
||||
|
||||
// Instead of SSH URL
|
||||
this.insteadOfKey = `url.${serverUrl.origin}/.insteadOf` // "origin" is SCHEME://HOSTNAME[:PORT]
|
||||
this.insteadOfKey = `url.${baseURL}/.insteadOf` // "origin" is SCHEME://HOSTNAME[:PORT]
|
||||
this.insteadOfValues.push(`git@${serverUrl.hostname}:`)
|
||||
if (this.settings.workflowOrganizationId) {
|
||||
this.insteadOfValues.push(
|
||||
|
|
|
@ -16,17 +16,23 @@ export function getFetchUrl(settings: IGitSourceSettings): string {
|
|||
}
|
||||
|
||||
// "origin" is SCHEME://HOSTNAME[:PORT]
|
||||
return `${serviceUrl.origin}/${encodedOwner}/${encodedName}`
|
||||
const baseURL = getBaseUrl(serviceUrl.href)
|
||||
return `${baseURL}/${encodedOwner}/${encodedName}`
|
||||
}
|
||||
|
||||
export function getServerUrl(url?: string): URL {
|
||||
let urlValue =
|
||||
const urlValue =
|
||||
url && url.trim().length > 0
|
||||
? url
|
||||
: process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||
return new URL(urlValue)
|
||||
}
|
||||
|
||||
export function getBaseUrl(url: string): string {
|
||||
const matcher = url.match(/^[^?]+/)
|
||||
return (matcher && matcher[0].replace(/\/+$/g, '')) || ''
|
||||
}
|
||||
|
||||
export function getServerApiUrl(url?: string): string {
|
||||
let apiUrl = 'https://api.github.com'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue