From 7b41d3370ca739da2a56505bdd00d5a9522b3a53 Mon Sep 17 00:00:00 2001 From: Ivan Demidov Date: Mon, 20 Jul 2020 10:28:11 +0300 Subject: [PATCH] perf: normalize url, close #2 --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index d8c5709..b54a19a 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,4 @@ +const normalizeUrl = require('normalize-url'); const rule = require('unified-lint-rule'); var visit = require('unist-util-visit') @@ -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)