summaryrefslogtreecommitdiff
path: root/lualibs-url.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-09-21 04:44:56 -0700
committerPhilipp Gesang <phg42.2a@gmail.com>2013-09-21 04:44:56 -0700
commitbc287b4f6bb89c78ec57e0e0871fa054075efdf1 (patch)
tree7e636bed27130e0b4846a7d41dfcf50e12a83492 /lualibs-url.lua
parent49880e8803d8f813aebcb15a5ecb6dc70d0caa17 (diff)
parentd96d015887e6fcbe1ca8defcec44cb794421785d (diff)
downloadlualibs-bc287b4f6bb89c78ec57e0e0871fa054075efdf1.tar.gz
Merge pull request #19 from phi-gamma/master
sync with Context as of 2013-09-21
Diffstat (limited to 'lualibs-url.lua')
-rw-r--r--lualibs-url.lua16
1 files changed, 11 insertions, 5 deletions
diff --git a/lualibs-url.lua b/lualibs-url.lua
index 4624a05..7b7910f 100644
--- a/lualibs-url.lua
+++ b/lualibs-url.lua
@@ -79,12 +79,18 @@ setmetatable(escapes, { __index = function(t,k)
return v
end })
-local escaper = Cs((R("09","AZ","az")^1 + P(" ")/"%%20" + S("-./_")^1 + P(1) / escapes)^0) -- space happens most
-local unescaper = Cs((escapedchar + 1)^0)
+local escaper = Cs((R("09","AZ","az")^1 + P(" ")/"%%20" + S("-./_")^1 + P(1) / escapes)^0) -- space happens most
+local unescaper = Cs((escapedchar + 1)^0)
+local getcleaner = Cs((P("+++") / "%%2B" + P("+") / "%%20" + P(1))^1)
-lpegpatterns.urlunescaped = escapedchar
-lpegpatterns.urlescaper = escaper
-lpegpatterns.urlunescaper = unescaper
+lpegpatterns.urlunescaped = escapedchar
+lpegpatterns.urlescaper = escaper
+lpegpatterns.urlunescaper = unescaper
+lpegpatterns.urlgetcleaner = getcleaner
+
+function url.unescapeget(str)
+ return lpegmatch(getcleaner,str)
+end
-- todo: reconsider Ct as we can as well have five return values (saves a table)
-- so we can have two parsers, one with and one without