Skip to content

Commit 39106e5

Browse files
authored
fix(alias): allow project name with invalid url characters (#44)
1 parent a1a5f55 commit 39106e5

File tree

1 file changed

+7
-3
lines changed
  • vercel-deployment-task-source/src

1 file changed

+7
-3
lines changed

vercel-deployment-task-source/src/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ async function run() {
245245
getStagingPrefix(vercelOrgId, vercelToken),
246246
]);
247247
const escapedBranchName = branchName.replace(/[^a-zA-Z0-9\-]-?/g, "-");
248+
const escapedProjectName = projectName.replace(
249+
/[^a-zA-Z0-9\-]-?/g,
250+
"-"
251+
);
248252
/**
249253
* Truncating branch name according to RFC 1035 if necessary
250254
* Maximum length is 63 characters.
@@ -272,8 +276,8 @@ async function run() {
272276
* longer-project-name-feature-prefix-12346-my-second-f.vercel.app
273277
*/
274278
const branchNameAllowedLength =
275-
50 - projectName.length - stagingPrefix.length;
276-
let aliasHostname = `${projectName}-${escapedBranchName}-${stagingPrefix}.vercel.app`;
279+
50 - escapedProjectName.length - stagingPrefix.length;
280+
let aliasHostname = `${escapedProjectName}-${escapedBranchName}-${stagingPrefix}.vercel.app`;
277281

278282
if (escapedBranchName.length > branchNameAllowedLength) {
279283
// Calculate the maximum length of the branchName by removing the stagingPrefix and the dash
@@ -294,7 +298,7 @@ async function run() {
294298
}
295299

296300
// Remove the stagingPrefix from the aliasHostname and use the extended aliasingBranchName
297-
aliasHostname = `${projectName}-${aliasingBranchName}.vercel.app`;
301+
aliasHostname = `${escapedProjectName}-${aliasingBranchName}.vercel.app`;
298302
}
299303

300304
deployURL = `https://${aliasHostname}`;

0 commit comments

Comments
 (0)