@adobe/spacecat-shared-utils 1.11.5 → 1.12.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 +14 -0
- package/package.json +1 -1
- package/src/index.d.ts +8 -1
- 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.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)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add composeAuditURL to helpers ([b7d4244](https://github.com/adobe/spacecat-shared/commit/b7d42447380915204a702e9fb1dfc4ecd4e5795c))
|
|
7
|
+
|
|
8
|
+
# [@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)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* docs for dateAfterDays ([86c39de](https://github.com/adobe/spacecat-shared/commit/86c39dec9d6ce937b37a4a74fefe4973cd51aef6))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-utils-v1.11.5](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.11.4...@adobe/spacecat-shared-utils-v1.11.5) (2024-02-26)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export function toBoolean(value: unknown): boolean;
|
|
|
35
35
|
|
|
36
36
|
export function isValidUrl(urlString: string): boolean;
|
|
37
37
|
|
|
38
|
-
export function dateAfterDays(days:
|
|
38
|
+
export function dateAfterDays(days: number): Date;
|
|
39
39
|
|
|
40
40
|
export function sqsWrapper(fn: (message: object, context: object) => Promise<Response>):
|
|
41
41
|
(request: object, context: object) => Promise<Response>;
|
|
@@ -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 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,
|