1
0
Fork 0
mirror of https://github.com/actions/checkout.git synced 2025-03-31 05:20:06 +02:00

alter getBaseUrl

This commit is contained in:
Frank 2023-10-14 23:06:51 +08:00
parent 5f56636ef8
commit 5e05fe08e6

View file

@ -1,6 +1,6 @@
import * as assert from 'assert' import * as assert from 'assert'
import {URL} from 'url' import { URL } from 'url'
import {IGitSourceSettings} from './git-source-settings' import { IGitSourceSettings } from './git-source-settings'
export function getFetchUrl(settings: IGitSourceSettings): string { export function getFetchUrl(settings: IGitSourceSettings): string {
assert.ok( assert.ok(
@ -16,7 +16,7 @@ export function getFetchUrl(settings: IGitSourceSettings): string {
} }
// "origin" is SCHEME://HOSTNAME[:PORT] // "origin" is SCHEME://HOSTNAME[:PORT]
const baseURL = getBaseUrl(serviceUrl.href) const baseURL = getBaseUrl(serviceUrl)
return `${baseURL}/${encodedOwner}/${encodedName}` return `${baseURL}/${encodedOwner}/${encodedName}`
} }
@ -28,9 +28,8 @@ export function getServerUrl(url?: string): URL {
return new URL(urlValue) return new URL(urlValue)
} }
export function getBaseUrl(url: string): string { function getBaseUrl(u: URL) {
const matcher = url.match(/^[^?]+/) return u.protocol + "//" + u.host + u.pathname.replace(/\/+$/g, '');
return (matcher && matcher[0].replace(/\/+$/g, '')) || ''
} }
export function getServerApiUrl(url?: string): string { export function getServerApiUrl(url?: string): string {