Skip to content

Commit

Permalink
fix(@angular/cli): don't break deployUrl with scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva committed Mar 10, 2017
1 parent c8e5359 commit fd0ca3e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 9 additions & 3 deletions packages/@angular/cli/models/webpack-configs/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,15 @@ export function getStylesConfig(wco: WebpackConfigOptions) {
if (!URL.startsWith('/') || URL.startsWith('//')) {
return URL;
}
// Join together base-href, deploy-url and the original URL.
// Also dedupe multiple slashes into single ones.
return `/${baseHref || ''}/${deployUrl || ''}/${URL}`.replace(/\/\/+/g, '/');

if (deployUrl.match(/:\/\//)) {
// If deployUrl contains a scheme, ignore baseHref use deployUrl as is.
return `${deployUrl.replace(/\/$/, '')}${URL}`;
} else {
// Join together base-href, deploy-url and the original URL.
// Also dedupe multiple slashes into single ones.
return `/${baseHref || ''}/${deployUrl || ''}/${URL}`.replace(/\/\/+/g, '/');
}
}
};
const urlPlugin = postcssUrl(postcssUrlOptions);
Expand Down
9 changes: 8 additions & 1 deletion tests/e2e/tests/build/css-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ export default function () {
.then(() => expectToFail(() => expectFileToExist('dist/component-img-absolute.svg')))
.then(() => expectFileMatchToExist('./dist', /global-img-relative\.[0-9a-f]{20}\.svg/))
.then(() => expectFileMatchToExist('./dist', /component-img-relative\.[0-9a-f]{20}\.svg/))
// Also check with base-href and deploy-url flags.
// Check urls with scheme are used as is.
.then(() => ng('build', '--base-href=/base/', '--deploy-url=http://deploy.url/',
'--extract-css'))
.then(() => expectFileToMatch('dist/styles.bundle.css',
/url\(http:\/\/deploy.url\/global-img-relative\.svg\)/))
.then(() => expectFileToMatch('dist/main.bundle.js',
/url\(http:\/\/deploy.url\/component-img-relative\.svg\)/))
// Check with base-href and deploy-url flags.
.then(() => ng('build', '--base-href=/base/', '--deploy-url=deploy/',
'--extract-css', '--aot'))
.then(() => expectFileToMatch('dist/styles.bundle.css',
Expand Down

0 comments on commit fd0ca3e

Please sign in to comment.