@adobe/spacecat-shared-utils 1.11.6 → 1.12.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 +14 -0
- package/package.json +1 -1
- package/src/index.d.ts +7 -0
- package/src/index.js +1 -0
- package/src/url-helpers.js +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-utils-v1.12.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.12.0...@adobe/spacecat-shared-utils-v1.12.1) (2024-02-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* composeAuditUrl docs ([e0b8db0](https://github.com/adobe/spacecat-shared/commit/e0b8db0b147f997e4a424c344474d0ddbf64fa14))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-utils-v1.12.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.11.6...@adobe/spacecat-shared-utils-v1.12.0) (2024-02-27)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add composeAuditURL to helpers ([b7d4244](https://github.com/adobe/spacecat-shared/commit/b7d42447380915204a702e9fb1dfc4ecd4e5795c))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-utils-v1.11.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.11.5...@adobe/spacecat-shared-utils-v1.11.6) (2024-02-26)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -84,3 +84,10 @@ declare function stripWWW(url: string): string;
|
|
|
84
84
|
* @returns The composed base URL.
|
|
85
85
|
*/
|
|
86
86
|
declare function composeBaseURL(domain: string): string;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Composes an audit URL by applying a series of transformations to the given url.
|
|
90
|
+
* @param url - The url to compose the audit URL from.
|
|
91
|
+
* @returns The composed audit URL.
|
|
92
|
+
*/
|
|
93
|
+
declare async function composeAuditURL(url: string): string;
|
package/src/index.js
CHANGED
package/src/url-helpers.js
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { context as h2, h1 } from '@adobe/fetch';
|
|
14
|
+
|
|
15
|
+
/* c8 ignore next 3 */
|
|
16
|
+
export const { fetch } = process.env.HELIX_FETCH_FORCE_HTTP1
|
|
17
|
+
? h1()
|
|
18
|
+
: h2();
|
|
13
19
|
/**
|
|
14
20
|
* Prepends 'https://' schema to the URL if it's not already present.
|
|
15
21
|
* @param {string} url - The URL to modify.
|
|
@@ -72,8 +78,16 @@ function composeBaseURL(domain) {
|
|
|
72
78
|
return baseURL;
|
|
73
79
|
}
|
|
74
80
|
|
|
81
|
+
async function composeAuditURL(url) {
|
|
82
|
+
const urlWithScheme = prependSchema(url);
|
|
83
|
+
const resp = await fetch(urlWithScheme);
|
|
84
|
+
const finalUrl = resp.url.split('://')[1];
|
|
85
|
+
return stripTrailingSlash(finalUrl);
|
|
86
|
+
}
|
|
87
|
+
|
|
75
88
|
export {
|
|
76
89
|
composeBaseURL,
|
|
90
|
+
composeAuditURL,
|
|
77
91
|
prependSchema,
|
|
78
92
|
stripPort,
|
|
79
93
|
stripTrailingDot,
|