@adobe/spacecat-shared-utils 1.30.0 → 1.30.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [@adobe/spacecat-shared-utils-v1.30.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.30.0...@adobe/spacecat-shared-utils-v1.30.1) (2025-02-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * composeAuditURL user agent failing for some sites ([#583](https://github.com/adobe/spacecat-shared/issues/583)) ([81bd136](https://github.com/adobe/spacecat-shared/commit/81bd136693ded29130b73b1c0258b6727104f5e1))
7
+
1
8
  # [@adobe/spacecat-shared-utils-v1.30.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.29.0...@adobe/spacecat-shared-utils-v1.30.0) (2025-02-06)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-utils",
3
- "version": "1.30.0",
3
+ "version": "1.30.1",
4
4
  "description": "Shared modules of the Spacecat Services - utils",
5
5
  "type": "module",
6
6
  "engines": {
package/src/index.d.ts CHANGED
@@ -99,10 +99,11 @@ declare function composeBaseURL(domain: string): string;
99
99
 
100
100
  /**
101
101
  * Composes an audit URL by applying a series of transformations to the given url.
102
- * @param url - The url to compose the audit URL from.
102
+ * @param {string} url - The url to compose the audit URL from.
103
+ * @param {string} [userAgent] - Optional user agent to use in the audit URL.
103
104
  * @returns a promise that resolves the composed audit URL.
104
105
  */
105
- declare function composeAuditURL(url: string): Promise<string>;
106
+ declare function composeAuditURL(url: string, userAgent: string): Promise<string>;
106
107
 
107
108
  /**
108
109
  * Resolves the name of the secret based on the function version.
@@ -83,13 +83,23 @@ function composeBaseURL(domain) {
83
83
  return baseURL;
84
84
  }
85
85
 
86
- async function composeAuditURL(url) {
86
+ /**
87
+ * Composes an audit URL by applying a series of transformations to the given url.
88
+ * @param {string} url - The url to compose the audit URL from.
89
+ * @param {string} [userAgent] - Optional user agent to use in the audit URL.
90
+ * @returns a promise that resolves the composed audit URL.
91
+ */
92
+ async function composeAuditURL(url, userAgent) {
87
93
  const urlWithScheme = prependSchema(url);
94
+
95
+ const headers = {};
96
+ if (userAgent) {
97
+ headers['User-Agent'] = userAgent;
98
+ }
99
+
88
100
  const resp = await fetch(urlWithScheme, {
89
101
  method: 'GET',
90
- headers: {
91
- 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
92
- },
102
+ headers,
93
103
  });
94
104
  const finalUrl = resp.url.split('://')[1];
95
105
  return stripTrailingSlash(finalUrl);