@hasna/shortlinks 0.1.20 → 0.1.21

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/cli/index.js CHANGED
@@ -3335,7 +3335,9 @@ function normalizeHostname(input) {
3335
3335
  throw new Error(`Invalid domain: ${input}`);
3336
3336
  }
3337
3337
  hostname = hostname.replace(/\.$/, "");
3338
- if (!/^[a-z0-9.-]+$/.test(hostname) || hostname.includes("..")) {
3338
+ const labels = hostname.split(".");
3339
+ const labelsAreValid = labels.every((label) => label.length >= 1 && label.length <= 63 && /^[a-z0-9-]+$/.test(label) && !label.startsWith("-") && !label.endsWith("-"));
3340
+ if (hostname.length > 253 || !labelsAreValid) {
3339
3341
  throw new Error(`Invalid domain: ${input}`);
3340
3342
  }
3341
3343
  return hostname;
@@ -20,7 +20,9 @@ function normalizeHostname(input) {
20
20
  throw new Error(`Invalid domain: ${input}`);
21
21
  }
22
22
  hostname = hostname.replace(/\.$/, "");
23
- if (!/^[a-z0-9.-]+$/.test(hostname) || hostname.includes("..")) {
23
+ const labels = hostname.split(".");
24
+ const labelsAreValid = labels.every((label) => label.length >= 1 && label.length <= 63 && /^[a-z0-9-]+$/.test(label) && !label.startsWith("-") && !label.endsWith("-"));
25
+ if (hostname.length > 253 || !labelsAreValid) {
24
26
  throw new Error(`Invalid domain: ${input}`);
25
27
  }
26
28
  return hostname;
package/dist/index.js CHANGED
@@ -71,7 +71,9 @@ function normalizeHostname(input) {
71
71
  throw new Error(`Invalid domain: ${input}`);
72
72
  }
73
73
  hostname = hostname.replace(/\.$/, "");
74
- if (!/^[a-z0-9.-]+$/.test(hostname) || hostname.includes("..")) {
74
+ const labels = hostname.split(".");
75
+ const labelsAreValid = labels.every((label) => label.length >= 1 && label.length <= 63 && /^[a-z0-9-]+$/.test(label) && !label.startsWith("-") && !label.endsWith("-"));
76
+ if (hostname.length > 253 || !labelsAreValid) {
75
77
  throw new Error(`Invalid domain: ${input}`);
76
78
  }
77
79
  return hostname;
package/dist/server.js CHANGED
@@ -72,7 +72,9 @@ function normalizeHostname(input) {
72
72
  throw new Error(`Invalid domain: ${input}`);
73
73
  }
74
74
  hostname = hostname.replace(/\.$/, "");
75
- if (!/^[a-z0-9.-]+$/.test(hostname) || hostname.includes("..")) {
75
+ const labels = hostname.split(".");
76
+ const labelsAreValid = labels.every((label) => label.length >= 1 && label.length <= 63 && /^[a-z0-9-]+$/.test(label) && !label.startsWith("-") && !label.endsWith("-"));
77
+ if (hostname.length > 253 || !labelsAreValid) {
76
78
  throw new Error(`Invalid domain: ${input}`);
77
79
  }
78
80
  return hostname;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/shortlinks",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "CLI-only shortlink manager for custom domains, click tracking, Cloudflare setup, and @hasna cloud sync",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",