Skip to content

Commit d53f458

Browse files
tomastrajanfilipesilva
authored andcommitted
feat(@angular/cli): add trailing slash to deployUrl when missing
Closes #7295
1 parent b1558f2 commit d53f458

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

+5
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

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ng } from '../../utils/process';
22
import { copyProjectAsset } from '../../utils/assets';
33
import { expectFileToMatch, writeMultipleFiles } from '../../utils/fs';
44
import { updateJsonFile } from '../../utils/project';
5+
import { getGlobalVariable } from '../../utils/env';
56

67

78
export default function () {
@@ -27,5 +28,13 @@ export default function () {
2728
// verify --deploy-url is applied to non-extracted css urls
2829
.then(() => ng('build', '--deploy-url=deployUrl/', '--extract-css=false'))
2930
.then(() => expectFileToMatch('dist/styles.bundle.js',
30-
/__webpack_require__.p \+ \"more\.[0-9a-f]{20}\.png\"/));
31+
/__webpack_require__.p \+ \"more\.[0-9a-f]{20}\.png\"/))
32+
.then(() => expectFileToMatch('dist/inline.bundle.js',
33+
/__webpack_require__\.p = "deployUrl\/";/))
34+
// verify slash is appended to the end of --deploy-url if missing
35+
.then(() => ng('build', '--deploy-url=deployUrl', '--extract-css=false'))
36+
// skip this in ejected tests
37+
.then(() => getGlobalVariable('argv').eject
38+
? Promise.resolve()
39+
: expectFileToMatch('dist/inline.bundle.js', /__webpack_require__\.p = "deployUrl\/";/));
3140
}

0 commit comments

Comments
 (0)