scraply 1.0.12 → 1.0.13
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/package.json +1 -1
- package/src/utils/format/formatData.js +16 -11
package/package.json
CHANGED
|
@@ -9,17 +9,22 @@ export const formatData = (entry) => {
|
|
|
9
9
|
const isExcluded = CONFIG.DATA_FORMATTER.EXCLUDED_PATTERNS.some(pattern => new RegExp(pattern).test(entry.url));
|
|
10
10
|
|
|
11
11
|
if (!isExcluded) {
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
const pathSegments = pathname.split('/').filter(Boolean); // filter out empty segments
|
|
13
|
+
const categorisedPaths = CONFIG.DATA_FORMATTER.CATEGORISED_PATHS[url.origin];
|
|
14
|
+
|
|
15
|
+
if (categorisedPaths) {
|
|
16
|
+
// Try to match the full path segments, reducing specificity step by step
|
|
17
|
+
let categorisedPath = null;
|
|
18
|
+
|
|
19
|
+
for (let i = pathSegments.length; i >= 1; i--) {
|
|
20
|
+
const pathKey = pathSegments.slice(0, i).join('/');
|
|
21
|
+
categorisedPath = categorisedPaths[pathKey];
|
|
22
|
+
if (categorisedPath) break;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Fallback to wildcard match ('*') if no specific path is found
|
|
26
|
+
if (!categorisedPath) categorisedPath = categorisedPaths['*'];
|
|
27
|
+
if (categorisedPath) return path.join(CONFIG.DATA_FORMATTER.FORMATTED_PATH, categorisedPath); // Return the path where the data should be saved.
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
} catch (e) {
|