Skip to content

Commit

Permalink
Merge pull request #5 from steadyapp/develop
Browse files Browse the repository at this point in the history
Fix Issue where non-links were being removed from final output
  • Loading branch information
swimmadude66 authored Oct 10, 2018
2 parents 7cfb7fd + 039dfeb commit 6769354
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ deploy:
provider: npm
email: "opensource@steadyapp.com"
api_key:
secure: "HMuh0yxeUoz3xbwBdB0+PbMfYhVt3jY8TuaNQAdp59KVR+TaT9X2gGz/CgI6e2t84t7VN9vPKCnXbGnk0XZE1MmNAAnWnTnxbQS+jmtgKEs5EAZyte3rMO2REqUm2BdkEcjTd2pyFfweMvHYyEoq3qlcWa6aQv+jRgsQ5xMAQGUL0DGvoas/Esl3mjDt9sEqfHya9hbDr+gE/olLgv4MKH5aJOBZv28Pdk6j/vyOw/Y135BqxKMx4w7VdQ1cstj07BUTIdcw4/Yv1Wpsb9+cRdZ7M0aeg+ylgxsYDcG87zDMLt/CQHd2LENj7cMVq7WhKCRIU/vQxWJV9gquHJg5bnjyA1BgOtuer1kZPn2Sqw1LHhZr9o69dDZpKjfIrVt+zGYu1f1ucn0DHF0phe0Mnm5H9jNHcK0hgRy5jHE/ujrnQXTKqLBUKsxGhxkEHJNiFvBnj6n+T447tpjVMtUd6lEey2IgcMnCjqHZSNQLN3u4/zfABWBVuHdCs1RM3/cXirMx5Nmq4o9EfAHel6qYrSgQZgDHJxZwhihbm/wvauafMoW1F7MWHypJQtTkXVWXdkDPcxrz8Bb6eQ+Q0qplhiHFZQTITHfhTd8uwWv2F/h7CrpXx4a7/8kLcJeeMDRlREltaN7Xia7h3RpP0GYsHx5rXmmdWBNzdUYqNYFzlJs="
secure: "HMuh0yxeUoz3xbwBdB0+PbMfYhVt3jY8TuaNQAdp59KVR+TaT9X2gGz/CgI6e2t84t7VN9vPKCnXbGnk0XZE1MmNAAnWnTnxbQS+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ifA82/NZkEjfZd74x7ONi42zIltRp5D9SZmgb2F9vCbqXFjTtD8Mh5y5r3BLizNLoa+UlqeQdTm0tjzTvxs2gGtHMe5kUr9tqovPPRt14mEg/yGzt/dmNz8KPPgOrPq3Urk3R8fUUsHPQYLyEKp4jhcVY8jVUYADCaI7Cp8vd2IJrNMwRqVPoCzawz3tkb2ySzmr/5gyDvBnCnA0KYiE=
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html-webpack-link-type-plugin",
"version": "1.0.1",
"version": "1.0.2",
"description": "a plugin for html-webpack-plugin to allow for mimetype tagging of injected links",
"main": "dist/plugin.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions spec/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('HtmlWebpackLinkTypePlugin', () => {
const htmlContents = readFileSync(htmlFile).toString();
expect(!!htmlContents).to.be.true;
expect(/href="styles\.css"[^>]*?type="text\/css"/.test(htmlContents)).to.be.true;
expect(/src="app\.js"/.test(htmlContents)).to.be.true;
done();
});
});
Expand Down Expand Up @@ -109,6 +110,7 @@ describe('HtmlWebpackLinkTypePlugin', () => {
const htmlContents = readFileSync(htmlFile).toString();
expect(!!htmlContents).to.be.true;
expect(/href="styles\.css"[^>]*?type="testtype"/.test(htmlContents)).to.be.true;
expect(/src="app\.js"/.test(htmlContents)).to.be.true;
done();
});
});
Expand Down
16 changes: 7 additions & 9 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,15 @@ export class HtmlWebpackLinkTypePlugin {
}

private _transformAssets(assets: any[]): any[] {
const links = assets
.filter(e => e.tagName && e.tagName === 'link')
.filter(e => e.attributes && e.attributes.href);

links.forEach(l => {
const type = this._findMimeType(l.attributes.href);
if (type && type.length) {
l.attributes.type=type;
return assets.map(l => {
if (l.tagName && l.tagName === 'link' && l.attributes && l.attributes.href) {
const type = this._findMimeType(l.attributes.href);
if (type && type.length) {
l.attributes.type=type;
}
}
return l;
});
return links;
}

private _findMimeType(filename: string): string {
Expand Down

0 comments on commit 6769354

Please sign in to comment.