Skip to content

feat(@angular/cli): add trailing slash to deployUrl when missing #8740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/@angular/cli/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ const BuildCommand = Command.extend({
commandOptions.forceTsCommonjs = true;
}

// Add trailing slash if missing to prevent https://github.com/angular/angular-cli/issues/7295
if (commandOptions.deployUrl && commandOptions.deployUrl.substr(-1) !== '/') {
commandOptions.deployUrl += '/';
}

const BuildTask = require('../tasks/build').default;

const buildTask = new BuildTask({
Expand Down
11 changes: 10 additions & 1 deletion tests/e2e/tests/build/deploy-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ng } from '../../utils/process';
import { copyProjectAsset } from '../../utils/assets';
import { expectFileToMatch, writeMultipleFiles } from '../../utils/fs';
import { updateJsonFile } from '../../utils/project';
import { getGlobalVariable } from '../../utils/env';


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