@argos-ci/util 3.1.0 → 3.1.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/dist/browser.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  getMetadataPath,
3
3
  getScreenshotName,
4
4
  validateThreshold
5
- } from "./chunk-VMM7XHBS.js";
5
+ } from "./chunk-CBWOZNU5.js";
6
6
  export {
7
7
  getMetadataPath,
8
8
  getScreenshotName,
@@ -0,0 +1,41 @@
1
+ // src/metadata.ts
2
+ function getMetadataPath(screenshotPath) {
3
+ return screenshotPath + ".argos.json";
4
+ }
5
+
6
+ // src/name.ts
7
+ function getScreenshotName(name, options = {}) {
8
+ return sanitizePath(
9
+ `${name}${options.viewportWidth ? ` vw-${options.viewportWidth}` : ""}`
10
+ );
11
+ }
12
+ function sanitizePath(name) {
13
+ return name.split("/").map((filename) => sanitizeFilename(filename)).join("/");
14
+ }
15
+ function filenameReservedRegex() {
16
+ return /[<>:"/\\|?*\u0000-\u001F]|[. ]$/g;
17
+ }
18
+ function windowsReservedNameRegex() {
19
+ return /^(con|prn|aux|nul|com\d|lpt\d)$/i;
20
+ }
21
+ function sanitizeFilename(name) {
22
+ const replacement = "-";
23
+ const sanitized = name.replace(filenameReservedRegex(), replacement);
24
+ if (windowsReservedNameRegex().test(sanitized)) {
25
+ return `${sanitized}${replacement}`;
26
+ }
27
+ return sanitized;
28
+ }
29
+
30
+ // src/threshold.ts
31
+ function validateThreshold(threshold) {
32
+ if (threshold < 0 || threshold > 1) {
33
+ throw new Error("The threshold must be between 0 and 1.");
34
+ }
35
+ }
36
+
37
+ export {
38
+ getMetadataPath,
39
+ getScreenshotName,
40
+ validateThreshold
41
+ };
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  getMetadataPath,
3
3
  getScreenshotName,
4
4
  validateThreshold
5
- } from "./chunk-VMM7XHBS.js";
5
+ } from "./chunk-CBWOZNU5.js";
6
6
 
7
7
  // src/fs.ts
8
8
  import { randomBytes } from "crypto";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/util",
3
3
  "description": "Set of utilities used across all Argos SDKs.",
4
- "version": "3.1.0",
4
+ "version": "3.1.1",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -47,5 +47,5 @@
47
47
  "@types/node": "catalog:",
48
48
  "vitest": "catalog:"
49
49
  },
50
- "gitHead": "dfad527145f58037c1991c2a85ad8cdc0d8a1a3f"
50
+ "gitHead": "867a93c5ffc01d55c7385d3ac3903c4c3ab270b6"
51
51
  }