ajv-validator / ajv-validator/ajv-formats

uri format rejects valid path-empty URIs (e.g. "a:")

未關閉
#118 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
228
分支
42
PR 合併指標
30 天內沒有已合併 PR

描述

## Bug

The `uri` format in full mode incorrectly rejects `"a:"` which is a valid URI per [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986).

## Root Cause

[RFC 3986 §3](https://www.rfc-editor.org/rfc/rfc3986#section-3) defines hier-part as:

hier-part = "//" authority path-abempty
/ path-absolute
/ path-rootless
/ path-empty

The full mode URI regex covers three of these alternatives but is missing `path-empty` (zero characters after the scheme colon).

## Reproduction

These all behave correctly:
- `"a:b"` - valid (path-rootless)
- `"a:b/c"` - valid (path-rootless)
- `"http://example.com"` - valid (path-abempty)

This is wrong:
- `"a:"` - invalid (should be valid - path-empty)

## RFC Proof

[RFC 3986 §3](https://www.rfc-editor.org/rfc/rfc3986#section-3):
"URI = scheme ':' hier-part ..."
"hier-part = ... / path-empty"
"path-empty = 0"

`"a:"` = scheme "a" + colon + path-empty (zero chars) This is a valid URI. Full mode should accept it.

## Fast Mode

Fast mode correctly accepts `"a:"` because `[^\s]*` matches zero characters. Only full mode is affected.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。