Skip to content

Commit fd0ca3e

Browse files
committed
fix(@angular/cli): don't break deployUrl with scheme
Fix angular#5254
1 parent c8e5359 commit fd0ca3e

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

packages/@angular/cli/models/webpack-configs/styles.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,15 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
5252
if (!URL.startsWith('/') || URL.startsWith('//')) {
5353
return URL;
5454
}
55-
// Join together base-href, deploy-url and the original URL.
56-
// Also dedupe multiple slashes into single ones.
57-
return `/${baseHref || ''}/${deployUrl || ''}/${URL}`.replace(/\/\/+/g, '/');
55+
56+
if (deployUrl.match(/:\/\//)) {
57+
// If deployUrl contains a scheme, ignore baseHref use deployUrl as is.
58+
return `${deployUrl.replace(/\/$/, '')}${URL}`;
59+
} else {
60+
// Join together base-href, deploy-url and the original URL.
61+
// Also dedupe multiple slashes into single ones.
62+
return `/${baseHref || ''}/${deployUrl || ''}/${URL}`.replace(/\/\/+/g, '/');
63+
}
5864
}
5965
};
6066
const urlPlugin = postcssUrl(postcssUrlOptions);

tests/e2e/tests/build/css-urls.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,14 @@ export default function () {
4747
.then(() => expectToFail(() => expectFileToExist('dist/component-img-absolute.svg')))
4848
.then(() => expectFileMatchToExist('./dist', /global-img-relative\.[0-9a-f]{20}\.svg/))
4949
.then(() => expectFileMatchToExist('./dist', /component-img-relative\.[0-9a-f]{20}\.svg/))
50-
// Also check with base-href and deploy-url flags.
50+
// Check urls with scheme are used as is.
51+
.then(() => ng('build', '--base-href=/base/', '--deploy-url=http://deploy.url/',
52+
'--extract-css'))
53+
.then(() => expectFileToMatch('dist/styles.bundle.css',
54+
/url\(http:\/\/deploy.url\/global-img-relative\.svg\)/))
55+
.then(() => expectFileToMatch('dist/main.bundle.js',
56+
/url\(http:\/\/deploy.url\/component-img-relative\.svg\)/))
57+
// Check with base-href and deploy-url flags.
5158
.then(() => ng('build', '--base-href=/base/', '--deploy-url=deploy/',
5259
'--extract-css', '--aot'))
5360
.then(() => expectFileToMatch('dist/styles.bundle.css',

0 commit comments

Comments
 (0)