@adobe/spacecat-shared-utils 1.38.6 → 1.39.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 +4 -4
- package/src/functions.js +47 -0
- package/src/index.js +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-utils-v1.39.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.39.0...@adobe/spacecat-shared-utils-v1.39.1) (2025-06-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update external fixes ([#802](https://github.com/adobe/spacecat-shared/issues/802)) ([fc2cb47](https://github.com/adobe/spacecat-shared/commit/fc2cb47183948833f5b0a411ae78d1649e747a17))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-utils-v1.39.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.38.6...@adobe/spacecat-shared-utils-v1.39.0) (2025-06-12)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* introduce isValidHelixPreviewUrl in context of preflight audits ([#798](https://github.com/adobe/spacecat-shared/issues/798)) ([9e3fdd5](https://github.com/adobe/spacecat-shared/commit/9e3fdd5887e5b02e5a9248b4732f00f4bfa84f81))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-utils-v1.38.6](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.38.5...@adobe/spacecat-shared-utils-v1.38.6) (2025-06-07)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/spacecat-shared-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.39.1",
|
|
4
4
|
"description": "Shared modules of the Spacecat Services - utils",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@adobe/fetch": "4.2.2",
|
|
49
|
-
"@aws-sdk/client-s3": "3.
|
|
50
|
-
"@aws-sdk/client-secrets-manager": "3.
|
|
51
|
-
"@aws-sdk/client-sqs": "3.
|
|
49
|
+
"@aws-sdk/client-s3": "3.828.0",
|
|
50
|
+
"@aws-sdk/client-secrets-manager": "3.828.0",
|
|
51
|
+
"@aws-sdk/client-sqs": "3.828.0",
|
|
52
52
|
"@json2csv/plainjs": "7.0.6",
|
|
53
53
|
"aws-xray-sdk": "3.10.3",
|
|
54
54
|
"uuid": "11.1.0"
|
package/src/functions.js
CHANGED
|
@@ -261,6 +261,52 @@ function isValidIMSOrgId(imsOrgId) {
|
|
|
261
261
|
return IMS_ORG_ID_REGEX.test(imsOrgId);
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
+
/**
|
|
265
|
+
* Validates whether the given string is a valid Helix preview URL.
|
|
266
|
+
* Preview URLs have the format: https://ref--site--owner.domain
|
|
267
|
+
* where domain is typically .hlx.page, .aem.page, .hlx.live, etc.
|
|
268
|
+
*
|
|
269
|
+
* @param {string} urlString - The string to validate.
|
|
270
|
+
* @returns {boolean} True if the given string is a valid Helix preview URL.
|
|
271
|
+
*/
|
|
272
|
+
function isValidHelixPreviewUrl(urlString) {
|
|
273
|
+
try {
|
|
274
|
+
const url = new URL(urlString);
|
|
275
|
+
if (url.protocol !== 'https:') {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const parts = url.hostname.split('.');
|
|
280
|
+
if (parts.length < 2) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// making 3 parts: ref--site--owner
|
|
285
|
+
const subdomain = parts[0];
|
|
286
|
+
const subdomainParts = subdomain.split('--');
|
|
287
|
+
|
|
288
|
+
if (subdomainParts.length !== 3) {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (subdomainParts.some((part) => !part || part.trim() === '')) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const domain = parts.slice(1).join('.');
|
|
297
|
+
const validDomains = [
|
|
298
|
+
'hlx.page',
|
|
299
|
+
'hlx.live',
|
|
300
|
+
'aem.page',
|
|
301
|
+
'aem.live',
|
|
302
|
+
];
|
|
303
|
+
|
|
304
|
+
return validDomains.includes(domain);
|
|
305
|
+
} catch {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
264
310
|
export {
|
|
265
311
|
arrayEquals,
|
|
266
312
|
dateAfterDays,
|
|
@@ -280,5 +326,6 @@ export {
|
|
|
280
326
|
isValidUrl,
|
|
281
327
|
isValidUUID,
|
|
282
328
|
isValidIMSOrgId,
|
|
329
|
+
isValidHelixPreviewUrl,
|
|
283
330
|
toBoolean,
|
|
284
331
|
};
|