Skip to content

Commit

Permalink
fix: broken links in content meta tags and browserconfig.xml
Browse files Browse the repository at this point in the history
closes #51
  • Loading branch information
brunocodutra authored and jantimon committed Aug 14, 2019
1 parent 9e197f1 commit 51bd1f8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 19 deletions.
11 changes: 9 additions & 2 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ module.exports = function (content) {
return callback(new Error(err));
}

const assets = [...result.images, ...result.files].map(({name, contents}) => ({name: path + name, contents}));
const html = result.html.map((entry) => entry.replace(/(href=['"])/g, '$1' + publicPath + path)).sort().join('');
const refs = /(href=|content=|src=)(['"])([\w-]+[.](png|json|ico|xml))\2/g;
const html = result.html.map((entry) => entry.replace(refs, '$1$2' + publicPath + path + '$3$2')).sort().join('');
const images = result.images.map(({name, contents}) => ({name: path + name, contents}));
const files = result.files.map(({name, contents}) => ({
name: path + name,
contents: contents.replace(refs, '$1$2' + publicPath + path + '$3$2'),
}));

const assets = [...images, ...files];

return callback(null, 'module.exports = ' + JSON.stringify(msgpack.encode({html, assets}).toString('base64')));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="mstile-70x70.png"/>
<square150x150logo src="mstile-150x150.png"/>
<wide310x150logo src="mstile-310x150.png"/>
<square310x310logo src="mstile-310x310.png"/>
<square70x70logo src="assets-d7623eb944cd4f7d2cd59efc84d5b410/mstile-70x70.png"/>
<square150x150logo src="assets-d7623eb944cd4f7d2cd59efc84d5b410/mstile-150x150.png"/>
<wide310x150logo src="assets-d7623eb944cd4f7d2cd59efc84d5b410/mstile-310x150.png"/>
<square310x310logo src="assets-d7623eb944cd4f7d2cd59efc84d5b410/mstile-310x310.png"/>
<TileColor>#fff</TileColor>

</tile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="mstile-70x70.png"/>
<square150x150logo src="mstile-150x150.png"/>
<wide310x150logo src="mstile-310x150.png"/>
<square310x310logo src="mstile-310x310.png"/>
<square70x70logo src="assets-d7623eb944cd4f7d2cd59efc84d5b410/mstile-70x70.png"/>
<square150x150logo src="assets-d7623eb944cd4f7d2cd59efc84d5b410/mstile-150x150.png"/>
<wide310x150logo src="assets-d7623eb944cd4f7d2cd59efc84d5b410/mstile-310x150.png"/>
<square310x310logo src="assets-d7623eb944cd4f7d2cd59efc84d5b410/mstile-310x310.png"/>
<TileColor>#fff</TileColor>

</tile>
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/expected/generate-html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>Webpack App</title>
<link rel="apple-touch-icon" sizes="114x114" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-114x114.png"><link rel="apple-touch-icon" sizes="120x120" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-120x120.png"><link rel="apple-touch-icon" sizes="144x144" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-144x144.png"><link rel="apple-touch-icon" sizes="152x152" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-152x152.png"><link rel="apple-touch-icon" sizes="180x180" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-180x180.png"><link rel="apple-touch-icon" sizes="57x57" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-57x57.png"><link rel="apple-touch-icon" sizes="60x60" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-60x60.png"><link rel="apple-touch-icon" sizes="72x72" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-72x72.png"><link rel="apple-touch-icon" sizes="76x76" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-76x76.png"><link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 1)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-320x460.png"><link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-640x920.png"><link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-640x1096.png"><link rel="apple-touch-startup-image" media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-750x1294.png"><link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 736px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 3)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-1182x2208.png"><link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 736px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 3)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-1242x2148.png"><link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 1)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-748x1024.png"><link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-1496x2048.png"><link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 1)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-768x1004.png"><link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-1536x2008.png"><link rel="icon" type="image/png" sizes="16x16" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/favicon-16x16.png"><link rel="icon" type="image/png" sizes="228x228" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/coast-228x228.png"><link rel="icon" type="image/png" sizes="32x32" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/favicon-32x32.png"><link rel="manifest" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/manifest.json"><link rel="shortcut icon" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/favicon.ico"><link rel="yandex-tableau-widget" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/yandex-browser-manifest.json"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"><meta name="apple-mobile-web-app-title"><meta name="application-name"><meta name="mobile-web-app-capable" content="yes"><meta name="msapplication-TileColor" content="#fff"><meta name="msapplication-TileImage" content="mstile-144x144.png"><meta name="msapplication-config" content="browserconfig.xml"><meta name="theme-color" content="#fff"></head>
<link rel="apple-touch-icon" sizes="114x114" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-114x114.png"><link rel="apple-touch-icon" sizes="120x120" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-120x120.png"><link rel="apple-touch-icon" sizes="144x144" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-144x144.png"><link rel="apple-touch-icon" sizes="152x152" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-152x152.png"><link rel="apple-touch-icon" sizes="180x180" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-180x180.png"><link rel="apple-touch-icon" sizes="57x57" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-57x57.png"><link rel="apple-touch-icon" sizes="60x60" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-60x60.png"><link rel="apple-touch-icon" sizes="72x72" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-72x72.png"><link rel="apple-touch-icon" sizes="76x76" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-icon-76x76.png"><link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 1)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-320x460.png"><link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-640x920.png"><link rel="apple-touch-startup-image" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-640x1096.png"><link rel="apple-touch-startup-image" media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-750x1294.png"><link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 736px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 3)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-1182x2208.png"><link rel="apple-touch-startup-image" media="(device-width: 414px) and (device-height: 736px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 3)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-1242x2148.png"><link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 1)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-748x1024.png"><link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-1496x2048.png"><link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 1)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-768x1004.png"><link rel="apple-touch-startup-image" media="(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2)" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/apple-touch-startup-image-1536x2008.png"><link rel="icon" type="image/png" sizes="16x16" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/favicon-16x16.png"><link rel="icon" type="image/png" sizes="228x228" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/coast-228x228.png"><link rel="icon" type="image/png" sizes="32x32" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/favicon-32x32.png"><link rel="manifest" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/manifest.json"><link rel="shortcut icon" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/favicon.ico"><link rel="yandex-tableau-widget" href="assets-d7623eb944cd4f7d2cd59efc84d5b410/yandex-browser-manifest.json"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"><meta name="apple-mobile-web-app-title"><meta name="application-name"><meta name="mobile-web-app-capable" content="yes"><meta name="msapplication-TileColor" content="#fff"><meta name="msapplication-TileImage" content="assets-d7623eb944cd4f7d2cd59efc84d5b410/mstile-144x144.png"><meta name="msapplication-config" content="assets-d7623eb944cd4f7d2cd59efc84d5b410/browserconfig.xml"><meta name="theme-color" content="#fff"></head>
<body>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="mstile-70x70.png"/>
<square150x150logo src="mstile-150x150.png"/>
<wide310x150logo src="mstile-310x150.png"/>
<square310x310logo src="mstile-310x310.png"/>
<square70x70logo src="assets-d7623eb944cd4f7d2cd59efc84d5b410/mstile-70x70.png"/>
<square150x150logo src="assets-d7623eb944cd4f7d2cd59efc84d5b410/mstile-150x150.png"/>
<wide310x150logo src="assets-d7623eb944cd4f7d2cd59efc84d5b410/mstile-310x150.png"/>
<square310x310logo src="assets-d7623eb944cd4f7d2cd59efc84d5b410/mstile-310x310.png"/>
<TileColor>#fff</TileColor>

</tile>
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/expected/prefixed/path/name-browserconfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="mstile-70x70.png"/>
<square150x150logo src="mstile-150x150.png"/>
<wide310x150logo src="mstile-310x150.png"/>
<square310x310logo src="mstile-310x310.png"/>
<square70x70logo src="path/name-mstile-70x70.png"/>
<square150x150logo src="path/name-mstile-150x150.png"/>
<wide310x150logo src="path/name-mstile-310x150.png"/>
<square310x310logo src="path/name-mstile-310x310.png"/>
<TileColor>#fff</TileColor>

</tile>
Expand Down

0 comments on commit 51bd1f8

Please sign in to comment.