feedscout 1.6.0 → 1.6.1
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/dist/common/uris/guess/utils.cjs +13 -11
- package/dist/common/uris/guess/utils.js +13 -11
- package/dist/common/uris/headers/index.cjs +1 -1
- package/dist/common/uris/headers/index.js +1 -1
- package/dist/common/uris/html/index.cjs +1 -1
- package/dist/common/uris/html/index.js +1 -1
- package/dist/common/utils.cjs +4 -2
- package/dist/common/utils.js +4 -2
- package/package.json +3 -3
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
//#region src/common/uris/guess/utils.ts
|
|
2
|
+
const resolveUri = (uri, base, origin, pathname) => {
|
|
3
|
+
if (uri.startsWith("/")) return `${origin}${uri}`;
|
|
4
|
+
if (uri.startsWith("?")) return `${origin}${pathname}${uri}`;
|
|
5
|
+
return new URL(uri, base).toString();
|
|
6
|
+
};
|
|
2
7
|
const generateUrlCombinations = (baseUrls, uris) => {
|
|
3
8
|
return baseUrls.flatMap((base) => {
|
|
9
|
+
const parsed = new URL(base);
|
|
10
|
+
const origin = parsed.origin;
|
|
11
|
+
const pathname = parsed.pathname;
|
|
4
12
|
return uris.map((uri) => {
|
|
5
|
-
if (typeof uri === "string") return
|
|
6
|
-
return uri.map((alternative) =>
|
|
7
|
-
return new URL(alternative, base).toString();
|
|
8
|
-
});
|
|
13
|
+
if (typeof uri === "string") return resolveUri(uri, base, origin, pathname);
|
|
14
|
+
return uri.map((alternative) => resolveUri(alternative, base, origin, pathname));
|
|
9
15
|
});
|
|
10
16
|
});
|
|
11
17
|
};
|
|
12
18
|
const getWwwCounterpart = (baseUrl) => {
|
|
13
19
|
const url = new URL(baseUrl);
|
|
14
|
-
const
|
|
15
|
-
if (url.hostname.startsWith("www.")) {
|
|
16
|
-
|
|
17
|
-
return counterpart.origin;
|
|
18
|
-
}
|
|
19
|
-
counterpart.hostname = `www.${url.hostname}`;
|
|
20
|
-
return counterpart.origin;
|
|
20
|
+
const port = url.port ? `:${url.port}` : "";
|
|
21
|
+
if (url.hostname.startsWith("www.")) return `${url.protocol}//${url.hostname.slice(4)}${port}`;
|
|
22
|
+
return `${url.protocol}//www.${url.hostname}${port}`;
|
|
21
23
|
};
|
|
22
24
|
const getSubdomainVariants = (baseUrl, prefixes) => {
|
|
23
25
|
const url = new URL(baseUrl);
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
//#region src/common/uris/guess/utils.ts
|
|
2
|
+
const resolveUri = (uri, base, origin, pathname) => {
|
|
3
|
+
if (uri.startsWith("/")) return `${origin}${uri}`;
|
|
4
|
+
if (uri.startsWith("?")) return `${origin}${pathname}${uri}`;
|
|
5
|
+
return new URL(uri, base).toString();
|
|
6
|
+
};
|
|
2
7
|
const generateUrlCombinations = (baseUrls, uris) => {
|
|
3
8
|
return baseUrls.flatMap((base) => {
|
|
9
|
+
const parsed = new URL(base);
|
|
10
|
+
const origin = parsed.origin;
|
|
11
|
+
const pathname = parsed.pathname;
|
|
4
12
|
return uris.map((uri) => {
|
|
5
|
-
if (typeof uri === "string") return
|
|
6
|
-
return uri.map((alternative) =>
|
|
7
|
-
return new URL(alternative, base).toString();
|
|
8
|
-
});
|
|
13
|
+
if (typeof uri === "string") return resolveUri(uri, base, origin, pathname);
|
|
14
|
+
return uri.map((alternative) => resolveUri(alternative, base, origin, pathname));
|
|
9
15
|
});
|
|
10
16
|
});
|
|
11
17
|
};
|
|
12
18
|
const getWwwCounterpart = (baseUrl) => {
|
|
13
19
|
const url = new URL(baseUrl);
|
|
14
|
-
const
|
|
15
|
-
if (url.hostname.startsWith("www.")) {
|
|
16
|
-
|
|
17
|
-
return counterpart.origin;
|
|
18
|
-
}
|
|
19
|
-
counterpart.hostname = `www.${url.hostname}`;
|
|
20
|
-
return counterpart.origin;
|
|
20
|
+
const port = url.port ? `:${url.port}` : "";
|
|
21
|
+
if (url.hostname.startsWith("www.")) return `${url.protocol}//${url.hostname.slice(4)}${port}`;
|
|
22
|
+
return `${url.protocol}//www.${url.hostname}${port}`;
|
|
21
23
|
};
|
|
22
24
|
const getSubdomainVariants = (baseUrl, prefixes) => {
|
|
23
25
|
const url = new URL(baseUrl);
|
|
@@ -19,7 +19,7 @@ const discoverUrisFromHeaders = (headers, options) => {
|
|
|
19
19
|
if (!rel) continue;
|
|
20
20
|
if (require_utils.matchesAnyOfLinkSelectors(rel, type, options.linkSelectors)) uris.add(url);
|
|
21
21
|
}
|
|
22
|
-
return
|
|
22
|
+
return [...uris];
|
|
23
23
|
};
|
|
24
24
|
//#endregion
|
|
25
25
|
exports.discoverUrisFromHeaders = discoverUrisFromHeaders;
|
|
@@ -19,7 +19,7 @@ const discoverUrisFromHeaders = (headers, options) => {
|
|
|
19
19
|
if (!rel) continue;
|
|
20
20
|
if (matchesAnyOfLinkSelectors(rel, type, options.linkSelectors)) uris.add(url);
|
|
21
21
|
}
|
|
22
|
-
return
|
|
22
|
+
return [...uris];
|
|
23
23
|
};
|
|
24
24
|
//#endregion
|
|
25
25
|
export { discoverUrisFromHeaders };
|
|
@@ -13,7 +13,7 @@ const discoverUrisFromHtml = (html, options) => {
|
|
|
13
13
|
const parser = new htmlparser2.Parser(require_handlers.createHtmlUrisHandlers(context), { decodeEntities: true });
|
|
14
14
|
parser.write(html);
|
|
15
15
|
parser.end();
|
|
16
|
-
return
|
|
16
|
+
return [...context.discoveredUris];
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
19
19
|
exports.discoverUrisFromHtml = discoverUrisFromHtml;
|
|
@@ -13,7 +13,7 @@ const discoverUrisFromHtml = (html, options) => {
|
|
|
13
13
|
const parser = new Parser(createHtmlUrisHandlers(context), { decodeEntities: true });
|
|
14
14
|
parser.write(html);
|
|
15
15
|
parser.end();
|
|
16
|
-
return
|
|
16
|
+
return [...context.discoveredUris];
|
|
17
17
|
};
|
|
18
18
|
//#endregion
|
|
19
19
|
export { discoverUrisFromHtml };
|
package/dist/common/utils.cjs
CHANGED
|
@@ -23,7 +23,7 @@ const isHostOf = (url, hosts) => {
|
|
|
23
23
|
};
|
|
24
24
|
const includesAnyOf = (value, patterns, parser) => {
|
|
25
25
|
const parsedValue = parser ? parser(value) : value?.toLowerCase();
|
|
26
|
-
return patterns.
|
|
26
|
+
return patterns.some((pattern) => pattern && parsedValue?.includes(pattern.toLowerCase()));
|
|
27
27
|
};
|
|
28
28
|
const isAnyOf = (value, patterns, parser) => {
|
|
29
29
|
const parsedValue = parser ? parser(value) : value?.toLowerCase()?.trim();
|
|
@@ -42,7 +42,9 @@ const isOfAllowedMimeType = (type, allowedTypes) => {
|
|
|
42
42
|
return isAnyOf(type, allowedTypes, normalizeMimeType);
|
|
43
43
|
};
|
|
44
44
|
const omitEmpty = (array) => {
|
|
45
|
-
|
|
45
|
+
const result = [];
|
|
46
|
+
for (const item of array) if (item != null && item !== "") result.push(item);
|
|
47
|
+
return result;
|
|
46
48
|
};
|
|
47
49
|
const normalizeUrl = (url, baseUrl) => {
|
|
48
50
|
return baseUrl ? new URL(url, baseUrl).href : url;
|
package/dist/common/utils.js
CHANGED
|
@@ -23,7 +23,7 @@ const isHostOf = (url, hosts) => {
|
|
|
23
23
|
};
|
|
24
24
|
const includesAnyOf = (value, patterns, parser) => {
|
|
25
25
|
const parsedValue = parser ? parser(value) : value?.toLowerCase();
|
|
26
|
-
return patterns.
|
|
26
|
+
return patterns.some((pattern) => pattern && parsedValue?.includes(pattern.toLowerCase()));
|
|
27
27
|
};
|
|
28
28
|
const isAnyOf = (value, patterns, parser) => {
|
|
29
29
|
const parsedValue = parser ? parser(value) : value?.toLowerCase()?.trim();
|
|
@@ -42,7 +42,9 @@ const isOfAllowedMimeType = (type, allowedTypes) => {
|
|
|
42
42
|
return isAnyOf(type, allowedTypes, normalizeMimeType);
|
|
43
43
|
};
|
|
44
44
|
const omitEmpty = (array) => {
|
|
45
|
-
|
|
45
|
+
const result = [];
|
|
46
|
+
for (const item of array) if (item != null && item !== "") result.push(item);
|
|
47
|
+
return result;
|
|
46
48
|
};
|
|
47
49
|
const normalizeUrl = (url, baseUrl) => {
|
|
48
50
|
return baseUrl ? new URL(url, baseUrl).href : url;
|
package/package.json
CHANGED
|
@@ -112,9 +112,9 @@
|
|
|
112
112
|
},
|
|
113
113
|
"devDependencies": {
|
|
114
114
|
"@types/bun": "^1.3.10",
|
|
115
|
-
"kvalita": "1.
|
|
116
|
-
"tsdown": "^0.21.
|
|
115
|
+
"kvalita": "1.11.0",
|
|
116
|
+
"tsdown": "^0.21.4",
|
|
117
117
|
"vitepress": "^1.6.4"
|
|
118
118
|
},
|
|
119
|
-
"version": "1.6.
|
|
119
|
+
"version": "1.6.1"
|
|
120
120
|
}
|