Skip to content

Commit

Permalink
Add npmjs.com to weird hosts that add 'user-content-' in front of fra…
Browse files Browse the repository at this point in the history
…gments
  • Loading branch information
Munter committed Nov 16, 2019
1 parent 48cccd3 commit 5aae7ea
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const defaultSkipFilters = [require('./known-culprits/linkedin')];

const hyperlinkUserAgent = `Hyperlink v${version} (https://www.npmjs.com/package/hyperlink)`;

const userContentFragmentOrigins = [
'https://github.com',
'https://www.npmjs.com'
];

function checkCompatibility(asset, Class) {
if (typeof Class === 'undefined') {
Class = AssetGraph.Asset;
Expand Down Expand Up @@ -313,9 +318,7 @@ async function hyperlink(
} else {
reportTest({
...redirectReport,
expected: `${log[0].statusCode} ${url} --> 200 ${
log[log.length - 1].redirectUri
}`,
expected: `${log[0].statusCode} ${url} --> 200 ${log[log.length - 1].redirectUri}`,
actual,
ok: false
});
Expand Down Expand Up @@ -752,9 +755,9 @@ async function hyperlink(
actual: fragmentReport.expected
});
} else {
// Github does some weird things with mangling fragments and reversing it with runtime js
// Some hosts do weird things with mangling fragments and reversing it with runtime js
if (
asset.origin === 'https://github.com' &&
userContentFragmentOrigins.includes(asset.origin) &&
asset.ids.has(`user-content-${fragment.substr(1)}`)
) {
reportTest({
Expand Down

0 comments on commit 5aae7ea

Please sign in to comment.