@zachleat/fetch-links 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/links.js +15 -1
- package/package.json +1 -1
package/links.js
CHANGED
|
@@ -43,12 +43,22 @@ export class Links {
|
|
|
43
43
|
let normalized = originalUrl ? Links.normalizeUrl(url, originalUrl) : url;
|
|
44
44
|
let key = normalized;
|
|
45
45
|
let via = `${tagName}[${attr}]${node.attrs.rel ? `[rel="${node.attrs.rel}"]` : ""}`;
|
|
46
|
+
let type;
|
|
47
|
+
if(node.attrs.rel && (node.attrs.type === "application/atom+xml" || node.attrs.type === "application/rss+xml")) {
|
|
48
|
+
type = "feed";
|
|
49
|
+
}
|
|
50
|
+
|
|
46
51
|
if(urls.has(key)) {
|
|
47
|
-
urls.get(key)
|
|
52
|
+
let entry = urls.get(key);
|
|
53
|
+
entry.via.add(via);
|
|
54
|
+
if(!entry.type) {
|
|
55
|
+
entry.type = type;
|
|
56
|
+
}
|
|
48
57
|
} else {
|
|
49
58
|
urls.set(key, {
|
|
50
59
|
url: normalized,
|
|
51
60
|
via: new Set([via]),
|
|
61
|
+
type,
|
|
52
62
|
});
|
|
53
63
|
}
|
|
54
64
|
|
|
@@ -92,6 +102,10 @@ export class Links {
|
|
|
92
102
|
}
|
|
93
103
|
|
|
94
104
|
static onlyKeepExternal(entry, originalUrl) {
|
|
105
|
+
if(entry.type) { // keep feeds and other important types
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
|
|
95
109
|
let comparison = originalUrl || "https://example.com";
|
|
96
110
|
let u = new URL(entry.url, comparison);
|
|
97
111
|
return !u.toString().startsWith(comparison);
|