Skip to content

Commit 7ff30ef

Browse files
committed
Avoid zero-price display for missing challenges
1 parent cc1e840 commit 7ff30ef

4 files changed

Lines changed: 6 additions & 3 deletions

File tree

bin/x402-surface-check.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function parseArgs(argv) {
7878
}
7979

8080
function moneyFromAtomic(amount, decimals = 6) {
81+
if (amount === '' || amount === null || amount === undefined) return ''
8182
const numeric = Number(amount)
8283
if (!Number.isFinite(numeric)) return String(amount ?? '')
8384
const value = numeric / (10 ** decimals)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "x402-surface-check",
3-
"version": "0.2.4",
3+
"version": "0.2.5",
44
"description": "No-payment x402 public-surface checker for manifests, OpenAPI specs, and HTTP 402 challenges.",
55
"type": "module",
66
"bin": {

test/smoke.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ try {
275275
assert.match(needsParam.stdout, /validation HTTP 400 before a payment challenge/)
276276
assert.doesNotMatch(needsParam.stdout, /challenge is missing amount/)
277277
assert.doesNotMatch(needsParam.stdout, /does not repeat the resource URL/)
278+
assert.doesNotMatch(needsParam.stdout, /\$0\.000/)
278279

279280
const freeTrial = await execFileAsync('node', [
280281
'bin/x402-surface-check.mjs',
@@ -286,6 +287,7 @@ try {
286287

287288
assert.match(freeTrial.stdout, /returned 200 without a payment challenge/)
288289
assert.doesNotMatch(freeTrial.stdout, /challenge is missing amount/)
290+
assert.doesNotMatch(freeTrial.stdout, /\$0\.000/)
289291
}
290292
finally {
291293
await new Promise(resolve => server.close(resolve))

0 commit comments

Comments
 (0)