@crawlee/utils 4.0.0-beta.259 → 4.0.0-beta.260

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.
@@ -54,10 +54,8 @@ export declare enum EnqueueStrategy {
54
54
  export declare const UNSUPPORTED_SCHEME_MESSAGE = "unsupported URL scheme (only http and https are allowed)";
55
55
  /**
56
56
  * Check whether `target` matches `origin` under the given enqueue `strategy`. The URL scheme is not
57
- * considered here (use {@link filterUrl} for the combined scheme + strategy check).
58
- *
59
- * The `enqueueLinks` implementation in `@crawlee/basic` matches the same strategies via glob patterns
60
- * (see `packages/basic-crawler/src/internals/enqueue-links/enqueue-links.ts`) — keep the two in sync when changing either.
57
+ * considered here (use {@link filterUrl} for the combined scheme + strategy check). This is the single
58
+ * definition of the strategies, shared by `enqueueLinks`, sitemaps and robots.txt.
61
59
  */
62
60
  export declare function matchesEnqueueStrategy(strategy: EnqueueStrategy | `${EnqueueStrategy}`, target: URL, origin: URL): boolean;
63
61
  /**
package/internals/url.js CHANGED
@@ -71,10 +71,8 @@ function normalizeHostname(hostname) {
71
71
  }
72
72
  /**
73
73
  * Check whether `target` matches `origin` under the given enqueue `strategy`. The URL scheme is not
74
- * considered here (use {@link filterUrl} for the combined scheme + strategy check).
75
- *
76
- * The `enqueueLinks` implementation in `@crawlee/basic` matches the same strategies via glob patterns
77
- * (see `packages/basic-crawler/src/internals/enqueue-links/enqueue-links.ts`) — keep the two in sync when changing either.
74
+ * considered here (use {@link filterUrl} for the combined scheme + strategy check). This is the single
75
+ * definition of the strategies, shared by `enqueueLinks`, sitemaps and robots.txt.
78
76
  */
79
77
  export function matchesEnqueueStrategy(strategy, target, origin) {
80
78
  switch (strategy) {
@@ -87,8 +85,8 @@ export function matchesEnqueueStrategy(strategy, target, origin) {
87
85
  if (originDomain) {
88
86
  return originDomain === getDomain(target.hostname, { mixedInputs: false });
89
87
  }
90
- // No registrable domain (e.g. an IP address), fall back to comparing origins.
91
- return target.origin === origin.origin;
88
+ // No registrable domain (e.g. an IP address or `localhost`), fall back to the same hostname.
89
+ return matchesEnqueueStrategy('same-hostname', target, origin);
92
90
  }
93
91
  case 'same-origin':
94
92
  // Compare scheme/host/port directly so a trailing-dot host is normalized.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/utils",
3
- "version": "4.0.0-beta.259",
3
+ "version": "4.0.0-beta.260",
4
4
  "description": "A set of shared utilities that can be used by crawlers",
5
5
  "engines": {
6
6
  "node": ">=22.13.0"
@@ -43,8 +43,8 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@apify/validations": "^1.1.2",
46
- "@crawlee/http-client": "4.0.0-beta.259",
47
- "@crawlee/types": "4.0.0-beta.259",
46
+ "@crawlee/http-client": "4.0.0-beta.260",
47
+ "@crawlee/types": "4.0.0-beta.260",
48
48
  "@types/sax": "^1.2.7",
49
49
  "cheerio": "^1.2.0",
50
50
  "domhandler": "^6.0.1",
@@ -63,5 +63,5 @@
63
63
  }
64
64
  }
65
65
  },
66
- "gitHead": "8b6c21145fd782c4618503b633fd45f6ce8e2385"
66
+ "gitHead": "c96c87d09eb5df1bcdf6365563ea99739f612a35"
67
67
  }