Skip to content

Commit 90fddc5

Browse files
committed
fix(@angular/cli): publicPath should not be path.join
Using path.join removes duplicated slashes, like in https://. This code is the correct version used in the original html-webpack-plugin. Fixes #7650
1 parent 642f6ba commit 90fddc5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/@angular/cli/plugins/insert-concat-assets-webpack-plugin.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Add assets from `ConcatPlugin` to index.html.
2-
import * as path from 'path';
2+
33

44
export class InsertConcatAssetsWebpackPlugin {
55
// Priority list of where to insert asset.
@@ -24,7 +24,13 @@ export class InsertConcatAssetsWebpackPlugin {
2424
throw new Error(`Cannot find file for ${entryName} script.`);
2525
}
2626

27-
return path.join(htmlPluginData.assets.publicPath, fileName);
27+
if (htmlPluginData.assets.publicPath) {
28+
if (htmlPluginData.assets.publicPath.endsWith('/')) {
29+
return htmlPluginData.assets.publicPath + fileName;
30+
}
31+
return htmlPluginData.assets.publicPath + '/' + fileName;
32+
}
33+
return fileName;
2834
});
2935

3036
let insertAt = 0;

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

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export default function () {
2424
.then(() => expectFileToMatch('dist/index.html', 'deployUrl/main.bundle.js'))
2525
// verify --deploy-url isn't applied to extracted css urls
2626
.then(() => expectFileToMatch('dist/styles.bundle.css', /url\(more\.[0-9a-f]{20}\.svg\)/))
27+
.then(() => ng('build', '--deploy-url=http://example.com/some/path/', '--extract-css'))
28+
.then(() => expectFileToMatch('dist/index.html', 'http://example.com/some/path/main.bundle.js'))
2729
// verify option also works in config
2830
.then(() => updateJsonFile('.angular-cli.json', configJson => {
2931
const app = configJson['apps'][0];

0 commit comments

Comments
 (0)