@adobe/spacecat-shared-utils 1.45.0 → 1.46.0
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/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/url-helpers.js +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-utils-v1.46.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.45.0...@adobe/spacecat-shared-utils-v1.46.0) (2025-08-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* return null instead of throwing error ([#914](https://github.com/adobe/spacecat-shared/issues/914)) ([90760c0](https://github.com/adobe/spacecat-shared/commit/90760c040c46eab127c1bfc780a454875475fb64))
|
|
7
|
+
|
|
1
8
|
# [@adobe/spacecat-shared-utils-v1.45.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.44.3...@adobe/spacecat-shared-utils-v1.45.0) (2025-08-11)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
package/src/url-helpers.js
CHANGED
|
@@ -136,7 +136,7 @@ function getSpacecatRequestHeaders() {
|
|
|
136
136
|
* Resolve canonical URL for a given URL string by following redirect chain.
|
|
137
137
|
* @param {string} urlString - The URL string to normalize.
|
|
138
138
|
* @param {string} method - HTTP method to use ('HEAD' or 'GET').
|
|
139
|
-
* @returns {Promise<string>} A Promise that resolves to the canonical URL.
|
|
139
|
+
* @returns {Promise<string|null>} A Promise that resolves to the canonical URL or null if failed.
|
|
140
140
|
*/
|
|
141
141
|
async function resolveCanonicalUrl(urlString, method = 'HEAD') {
|
|
142
142
|
const headers = getSpacecatRequestHeaders();
|
|
@@ -158,15 +158,16 @@ async function resolveCanonicalUrl(urlString, method = 'HEAD') {
|
|
|
158
158
|
return resolveCanonicalUrl(urlString, 'GET');
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
// If the URL is not found,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
} catch (err) {
|
|
161
|
+
// If the URL is not found and we've tried both HEAD and GET, return null
|
|
162
|
+
return null;
|
|
163
|
+
} catch {
|
|
165
164
|
// If HEAD failed with network error and we haven't tried GET yet, retry with GET
|
|
166
165
|
if (method === 'HEAD') {
|
|
167
166
|
return resolveCanonicalUrl(urlString, 'GET');
|
|
168
167
|
}
|
|
169
|
-
|
|
168
|
+
|
|
169
|
+
// For all errors (both HTTP status and network), return null
|
|
170
|
+
return null;
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
|