Skip to content

Commit 3093e30

Browse files
committed
lpeg_patterns/uri: Export IP_literal
1 parent 7aa0ac2 commit 3093e30

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Parses URIs as described in [RFC-3986](https://tools.ietf.org/html/rfc3986).
7373
- `scheme` (pattern): matches the scheme portion of a URI
7474
- `userinfo` (pattern): matches the userinfo portion of a URI
7575
- `host` (pattern): matches the host portion of a URI
76+
- `IP_literal` (pattern): matches an IP based host portion of a URI. Capture is an [IPv4](#IPv4), [IPv6](#IPv6) or IPvFuture object
7677
- `port` (pattern): matches the port portion of a URI
7778
- `authority` (pattern): matches the authority portion of a URI; data is held in named group captures of `"userinfo"`, `"host"`, `"port"`
7879
- `path` (pattern): matches the path portion of a URI. Captures `nil` for the empty path.

lpeg_patterns/uri.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ local IPv6addrz = IPv6address * (P"%25" * ZoneID)^-1 / function(IPv6, zoneid)
5757
return IPv6
5858
end
5959

60-
local IP_literal = P"[" * ( IPv6addrz + IPvFuture ) * P"]"
61-
local IP_host = ( IP_literal + IPv4address ) / tostring
60+
_M.IP_literal = P"[" * (IPv6addrz + IPvFuture) * P"]"
61+
local IP_host = (_M.IP_literal + IPv4address) / tostring
6262
local reg_name = Cs((
6363
unreserved / string.lower
6464
+ _M.pct_encoded / function(s) return s:sub(1,1) == "%" and s or string.lower(s) end

0 commit comments

Comments
 (0)