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

Closes #7295
This commit is contained in:
tomastrajan 2017-12-05 17:27:39 +11:00 committed by Filipe Silva
parent b1558f2512
commit d53f45896b
2 changed files with 15 additions and 1 deletions

View File

@ -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({

View File

@ -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 () {
@ -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\/";/));
}