Skip to content

Commit 76ca580

Browse files
committed
feat(@angular/cli): add trailing slash to deployUrl when missing
Closes #7295
1 parent d5a5fe2 commit 76ca580

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/@angular/cli/commands/build.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ const BuildCommand = Command.extend({
239239
commandOptions.forceTsCommonjs = true;
240240
}
241241

242+
// Add trailing slash if missing to prevent https://github.com/angular/angular-cli/issues/7295
243+
if (commandOptions.deployUrl && commandOptions.deployUrl.substr(-1) !== '/') {
244+
commandOptions.deployUrl += '/';
245+
}
246+
242247
const BuildTask = require('../tasks/build').default;
243248

244249
const buildTask = new BuildTask({

tests/e2e/tests/build/deploy-url.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,11 @@ export default function () {
2727
// verify --deploy-url is applied to non-extracted css urls
2828
.then(() => ng('build', '--deploy-url=deployUrl/', '--extract-css=false'))
2929
.then(() => expectFileToMatch('dist/styles.bundle.js',
30-
/__webpack_require__.p \+ \"more\.[0-9a-f]{20}\.png\"/));
30+
/__webpack_require__.p \+ \"more\.[0-9a-f]{20}\.png\"/))
31+
.then(() => expectFileToMatch('dist/inline.bundle.js',
32+
/__webpack_require__\.p = "deployUrl\/";/))
33+
// verify slash is appended to the end of --deploy-url if missing
34+
.then(() => ng('build', '--deploy-url=deployUrl', '--extract-css=false'))
35+
.then(() => expectFileToMatch('dist/inline.bundle.js',
36+
/__webpack_require__\.p = "deployUrl\/";/));
3137
}

0 commit comments

Comments
 (0)