bulletin-deploy 0.5.0 → 0.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulletin-deploy",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
package/src/dotns.js CHANGED
@@ -160,7 +160,7 @@ export function computeDomainTokenId(label) {
160
160
  return BigInt(node);
161
161
  }
162
162
  export function countTrailingDigits(label) { let count = 0; for (let i = label.length - 1; i >= 0; i--) { const code = label.charCodeAt(i); if (code >= 48 && code <= 57) count++; else break; } return count; }
163
- export function stripTrailingDigits(label) { return label.replace(/\d+$/, ""); }
163
+ export function stripTrailingDigits(label) { return label.replace(/\d+$/, "").replace(/-$/, ""); }
164
164
 
165
165
  export function validateDomainLabel(label) {
166
166
  if (!/^[a-z0-9-]{3,}$/.test(label)) throw new Error("Invalid domain label: must contain only lowercase letters, digits, and hyphens, min 3 chars");
package/test/test.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { test, describe } from "node:test";
2
2
  import assert from "node:assert/strict";
3
3
  import { createCID, encodeContenthash } from "../src/deploy.js";
4
- import { validateDomainLabel, fetchNonce, TX_TIMEOUT_MS } from "../src/dotns.js";
4
+ import { validateDomainLabel, stripTrailingDigits, fetchNonce, TX_TIMEOUT_MS } from "../src/dotns.js";
5
5
 
6
6
  // ---------------------------------------------------------------------------
7
7
  // 1. createCID
@@ -86,7 +86,28 @@ describe("validateDomainLabel", () => {
86
86
  });
87
87
 
88
88
  // ---------------------------------------------------------------------------
89
- // 4. fetchNonce timeout
89
+ // 4. stripTrailingDigits
90
+ // ---------------------------------------------------------------------------
91
+ describe("stripTrailingDigits", () => {
92
+ test("strips trailing digits", () => {
93
+ assert.strictEqual(stripTrailingDigits("my-app00"), "my-app");
94
+ });
95
+
96
+ test("strips trailing hyphen after digits", () => {
97
+ assert.strictEqual(stripTrailingDigits("t3rminal-app-88-pr-80"), "t3rminal-app-88-pr");
98
+ });
99
+
100
+ test("handles no trailing digits", () => {
101
+ assert.strictEqual(stripTrailingDigits("my-app"), "my-app");
102
+ });
103
+
104
+ test("handles all digits suffix", () => {
105
+ assert.strictEqual(stripTrailingDigits("app-123"), "app");
106
+ });
107
+ });
108
+
109
+ // ---------------------------------------------------------------------------
110
+ // 5. fetchNonce timeout
90
111
  // ---------------------------------------------------------------------------
91
112
  describe("fetchNonce", () => {
92
113
  test(