Skip to content

Commit ece14fa

Browse files
committed
lpeg_patterns/uri: Export sub_delims
1 parent 24a5b87 commit ece14fa

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Parses URIs as described in [RFC-3986](https://tools.ietf.org/html/rfc3986).
8484
- `sane_host` (pattern): a variant that shouldn't match things that people would not normally consider valid hosts.
8585
- `sane_authority` (pattern): a variant that shouldn't match things that people would not normally consider valid hosts.
8686
- `pct_encoded` (pattern): matches a percent encoded octet, produces a capture of the normalised form.
87+
- `sub_delims` (pattern): the set of subcomponent delimeters
8788

8889

8990
### `email`

lpeg_patterns/uri.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ local IPv6address = require "lpeg_patterns.IPv6".IPv6address
2222

2323
local _M = {}
2424

25-
local sub_delims = S"!$&'()*+,;=" -- 2.2
25+
_M.sub_delims = S"!$&'()*+,;=" -- 2.2
2626
local unreserved = ALPHA + DIGIT + S"-._~" -- 2.3
2727
_M.pct_encoded = P"%" * (HEXDIG * HEXDIG / util.read_hex) / function(n)
2828
local c = string.char(n)
@@ -37,7 +37,7 @@ end -- 2.1
3737

3838
_M.scheme = ALPHA * (ALPHA + DIGIT + S"+-.")^0 / string.lower -- 3.1
3939

40-
_M.userinfo = Cs((unreserved + _M.pct_encoded + sub_delims + P":")^0) -- 3.2.1
40+
_M.userinfo = Cs((unreserved + _M.pct_encoded + _M.sub_delims + P":")^0) -- 3.2.1
4141

4242
-- Host 3.2.2
4343

@@ -48,7 +48,7 @@ end
4848
local function new_IPvFuture(version, string)
4949
return setmetatable({version=version, string=string}, IPvFuture_mt)
5050
end
51-
local IPvFuture = S"vV" * (HEXDIG^1/util.read_hex) * P"." * C((unreserved+sub_delims+P":")^1) / new_IPvFuture
51+
local IPvFuture = S"vV" * (HEXDIG^1/util.read_hex) * P"." * C((unreserved+_M.sub_delims+P":")^1) / new_IPvFuture
5252

5353
-- RFC 6874
5454
local ZoneID = Cs((unreserved + _M.pct_encoded)^1)
@@ -59,14 +59,14 @@ end
5959

6060
local IP_literal = P"[" * ( IPv6addrz + IPvFuture ) * P"]"
6161
local IP_host = ( IP_literal + IPv4address ) / tostring
62-
local host_char = unreserved / string.lower + _M.pct_encoded + sub_delims
62+
local host_char = unreserved / string.lower + _M.pct_encoded + _M.sub_delims
6363
local reg_name = Cs ( host_char^1 ) + Cc ( nil )
6464
_M.host = IP_host + reg_name
6565

6666
_M.port = DIGIT^0 / tonumber -- 3.2.3
6767

6868
-- Path 3.3
69-
local pchar = unreserved + _M.pct_encoded + sub_delims + S":@"
69+
local pchar = unreserved + _M.pct_encoded + _M.sub_delims + S":@"
7070
local segment = pchar^0
7171
_M.segment = Cs(segment)
7272
local segment_nz = pchar^1

0 commit comments

Comments
 (0)