@adobe/spacecat-shared-utils 1.38.5 → 1.39.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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [@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)
2
+
3
+
4
+ ### Features
5
+
6
+ * 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))
7
+
8
+ # [@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)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** update external fixes ([#794](https://github.com/adobe/spacecat-shared/issues/794)) ([756cc67](https://github.com/adobe/spacecat-shared/commit/756cc67513540b0fc69ead1b90345891fef64793))
14
+
1
15
  # [@adobe/spacecat-shared-utils-v1.38.5](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-utils-v1.38.4...@adobe/spacecat-shared-utils-v1.38.5) (2025-05-31)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-utils",
3
- "version": "1.38.5",
3
+ "version": "1.39.0",
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.821.0",
50
- "@aws-sdk/client-secrets-manager": "3.821.0",
51
- "@aws-sdk/client-sqs": "3.821.0",
49
+ "@aws-sdk/client-s3": "3.826.0",
50
+ "@aws-sdk/client-secrets-manager": "3.826.0",
51
+ "@aws-sdk/client-sqs": "3.826.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
  };
package/src/index.js CHANGED
@@ -29,6 +29,7 @@ export {
29
29
  isValidUrl,
30
30
  isValidUUID,
31
31
  isValidIMSOrgId,
32
+ isValidHelixPreviewUrl,
32
33
  toBoolean,
33
34
  } from './functions.js';
34
35