Skip to content
Permalink
9bfb9ba527
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
67 lines (63 sloc) 3.17 KB
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkArtifactFilePath = exports.checkArtifactName = void 0;
const core_1 = require("@actions/core");
/**
* Invalid characters that cannot be in the artifact name or an uploaded file. Will be rejected
* from the server if attempted to be sent over. These characters are not allowed due to limitations with certain
* file systems such as NTFS. To maintain platform-agnostic behavior, all characters that are not supported by an
* individual filesystem/platform will not be supported on all fileSystems/platforms
*
* FilePaths can include characters such as \ and / which are not permitted in the artifact name alone
*/
const invalidArtifactFilePathCharacters = new Map([
['"', ' Double quote "'],
[':', ' Colon :'],
['<', ' Less than <'],
['>', ' Greater than >'],
['|', ' Vertical bar |'],
['*', ' Asterisk *'],
['?', ' Question mark ?'],
['\r', ' Carriage return \\r'],
['\n', ' Line feed \\n']
]);
const invalidArtifactNameCharacters = new Map([
...invalidArtifactFilePathCharacters,
['\\', ' Backslash \\'],
['/', ' Forward slash /']
]);
/**
* Scans the name of the artifact to make sure there are no illegal characters
*/
function checkArtifactName(name) {
if (!name) {
throw new Error(`Artifact name: ${name}, is incorrectly provided`);
}
for (const [invalidCharacterKey, errorMessageForCharacter] of invalidArtifactNameCharacters) {
if (name.includes(invalidCharacterKey)) {
throw new Error(`Artifact name is not valid: ${name}. Contains the following character: ${errorMessageForCharacter}
Invalid characters include: ${Array.from(invalidArtifactNameCharacters.values()).toString()}
These characters are not allowed in the artifact name due to limitations with certain file systems such as NTFS. To maintain file system agnostic behavior, these characters are intentionally not allowed to prevent potential problems with downloads on different file systems.`);
}
}
core_1.info(`Artifact name is valid!`);
}
exports.checkArtifactName = checkArtifactName;
/**
* Scans the name of the filePath used to make sure there are no illegal characters
*/
function checkArtifactFilePath(path) {
if (!path) {
throw new Error(`Artifact path: ${path}, is incorrectly provided`);
}
for (const [invalidCharacterKey, errorMessageForCharacter] of invalidArtifactFilePathCharacters) {
if (path.includes(invalidCharacterKey)) {
throw new Error(`Artifact path is not valid: ${path}. Contains the following character: ${errorMessageForCharacter}
Invalid characters include: ${Array.from(invalidArtifactFilePathCharacters.values()).toString()}
The following characters are not allowed in files that are uploaded due to limitations with certain file systems such as NTFS. To maintain file system agnostic behavior, these characters are intentionally not allowed to prevent potential problems with downloads on different file systems.
`);
}
}
}
exports.checkArtifactFilePath = checkArtifactFilePath;
//# sourceMappingURL=path-and-artifact-name-validation.js.map