mirror of
https://gitea.com/actions/checkout.git
synced 2025-02-06 00:46:11 +08:00
Use concise WhitespaceMode
names
This commit is contained in:
parent
7fd13ec418
commit
55f79d95df
13
dist/index.js
vendored
13
dist/index.js
vendored
@ -2455,13 +2455,13 @@ function getFetchUrl(settings) {
|
|||||||
}
|
}
|
||||||
function getServerUrl(url) {
|
function getServerUrl(url) {
|
||||||
let resolvedUrl = process.env['GITHUB_SERVER_URL'] || 'https://github.com';
|
let resolvedUrl = process.env['GITHUB_SERVER_URL'] || 'https://github.com';
|
||||||
if (hasContent(url, WhitespaceMode.IgnorePureWhitespace)) {
|
if (hasContent(url, WhitespaceMode.Trim)) {
|
||||||
resolvedUrl = url;
|
resolvedUrl = url;
|
||||||
}
|
}
|
||||||
return new url_1.URL(resolvedUrl);
|
return new url_1.URL(resolvedUrl);
|
||||||
}
|
}
|
||||||
function getServerApiUrl(url) {
|
function getServerApiUrl(url) {
|
||||||
if (hasContent(url, WhitespaceMode.IgnorePureWhitespace)) {
|
if (hasContent(url, WhitespaceMode.Trim)) {
|
||||||
let serverUrl = getServerUrl(url);
|
let serverUrl = getServerUrl(url);
|
||||||
if (isGhes(url)) {
|
if (isGhes(url)) {
|
||||||
serverUrl.pathname = 'api/v3';
|
serverUrl.pathname = 'api/v3';
|
||||||
@ -2482,20 +2482,19 @@ function isGhes(url) {
|
|||||||
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost;
|
||||||
}
|
}
|
||||||
function pruneSuffix(text, suffix) {
|
function pruneSuffix(text, suffix) {
|
||||||
if (hasContent(suffix, WhitespaceMode.AllowPureWhitespace) &&
|
if (hasContent(suffix, WhitespaceMode.Preserve) && (text === null || text === void 0 ? void 0 : text.endsWith(suffix))) {
|
||||||
(text === null || text === void 0 ? void 0 : text.endsWith(suffix))) {
|
|
||||||
return text.substring(0, text.length - suffix.length);
|
return text.substring(0, text.length - suffix.length);
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
var WhitespaceMode;
|
var WhitespaceMode;
|
||||||
(function (WhitespaceMode) {
|
(function (WhitespaceMode) {
|
||||||
WhitespaceMode[WhitespaceMode["IgnorePureWhitespace"] = 0] = "IgnorePureWhitespace";
|
WhitespaceMode[WhitespaceMode["Trim"] = 0] = "Trim";
|
||||||
WhitespaceMode[WhitespaceMode["AllowPureWhitespace"] = 1] = "AllowPureWhitespace";
|
WhitespaceMode[WhitespaceMode["Preserve"] = 1] = "Preserve";
|
||||||
})(WhitespaceMode || (WhitespaceMode = {}));
|
})(WhitespaceMode || (WhitespaceMode = {}));
|
||||||
function hasContent(text, whitespaceMode) {
|
function hasContent(text, whitespaceMode) {
|
||||||
let refinedText = text !== null && text !== void 0 ? text : '';
|
let refinedText = text !== null && text !== void 0 ? text : '';
|
||||||
if (whitespaceMode == WhitespaceMode.IgnorePureWhitespace) {
|
if (whitespaceMode == WhitespaceMode.Trim) {
|
||||||
refinedText = refinedText.trim();
|
refinedText = refinedText.trim();
|
||||||
}
|
}
|
||||||
return refinedText.length > 0;
|
return refinedText.length > 0;
|
||||||
|
@ -22,7 +22,7 @@ export function getFetchUrl(settings: IGitSourceSettings): string {
|
|||||||
|
|
||||||
export function getServerUrl(url?: string): URL {
|
export function getServerUrl(url?: string): URL {
|
||||||
let resolvedUrl = process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
let resolvedUrl = process.env['GITHUB_SERVER_URL'] || 'https://github.com'
|
||||||
if (hasContent(url, WhitespaceMode.IgnorePureWhitespace)) {
|
if (hasContent(url, WhitespaceMode.Trim)) {
|
||||||
resolvedUrl = url!
|
resolvedUrl = url!
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ export function getServerUrl(url?: string): URL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getServerApiUrl(url?: string): string {
|
export function getServerApiUrl(url?: string): string {
|
||||||
if (hasContent(url, WhitespaceMode.IgnorePureWhitespace)) {
|
if (hasContent(url, WhitespaceMode.Trim)) {
|
||||||
let serverUrl = getServerUrl(url)
|
let serverUrl = getServerUrl(url)
|
||||||
if (isGhes(url)) {
|
if (isGhes(url)) {
|
||||||
serverUrl.pathname = 'api/v3'
|
serverUrl.pathname = 'api/v3'
|
||||||
@ -58,18 +58,15 @@ export function isGhes(url?: string): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function pruneSuffix(text: string, suffix: string) {
|
function pruneSuffix(text: string, suffix: string) {
|
||||||
if (
|
if (hasContent(suffix, WhitespaceMode.Preserve) && text?.endsWith(suffix)) {
|
||||||
hasContent(suffix, WhitespaceMode.AllowPureWhitespace) &&
|
|
||||||
text?.endsWith(suffix)
|
|
||||||
) {
|
|
||||||
return text.substring(0, text.length - suffix.length)
|
return text.substring(0, text.length - suffix.length)
|
||||||
}
|
}
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
enum WhitespaceMode {
|
enum WhitespaceMode {
|
||||||
IgnorePureWhitespace,
|
Trim,
|
||||||
AllowPureWhitespace
|
Preserve
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasContent(
|
function hasContent(
|
||||||
@ -77,7 +74,7 @@ function hasContent(
|
|||||||
whitespaceMode: WhitespaceMode
|
whitespaceMode: WhitespaceMode
|
||||||
): boolean {
|
): boolean {
|
||||||
let refinedText = text ?? ''
|
let refinedText = text ?? ''
|
||||||
if (whitespaceMode == WhitespaceMode.IgnorePureWhitespace) {
|
if (whitespaceMode == WhitespaceMode.Trim) {
|
||||||
refinedText = refinedText.trim()
|
refinedText = refinedText.trim()
|
||||||
}
|
}
|
||||||
return refinedText.length > 0
|
return refinedText.length > 0
|
||||||
|
Loading…
Reference in New Issue
Block a user