Skip to content

Commit

Permalink
perf: normalize url, close #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrum committed Jul 20, 2020
1 parent f27d1ed commit 7b41d33
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const normalizeUrl = require('normalize-url');
const rule = require('unified-lint-rule');
var visit = require('unist-util-visit')

Expand All @@ -10,7 +11,12 @@ function processor(tree, file) {
const links = new Map();

visit(tree, 'link', node => {
const {url} = node;
const url = normalizeUrl(node.url, {
removeDirectoryIndex: true,
stripHash: true,
stripProtocol: true,
removeQueryParameters: [/\.*/i]
});

if (links.has(url)) {
links.get(url).push(node)
Expand Down

0 comments on commit 7b41d33

Please sign in to comment.