Skip to content

Commit

Permalink
support - for uri
Browse files Browse the repository at this point in the history
  • Loading branch information
sumory committed Jun 10, 2017
1 parent 9eb222f commit ff6ec83
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/lor/lib/trie.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ local Node = require("lor.lib.node")
local NodeHolder = holder.NodeHolder
local Matched = holder.Matched
local mixin = utils.mixin
local valid_segment_tip = "valid path should only contains: [A-Za-z0-9._-~]"
local valid_segment_tip = "valid path should only contains: [A-Za-z0-9._%-~]"


local function check_segment(segment)
local tmp = string_gsub(segment, "([A-Za-z0-9._-~]+)", "")
local tmp = string_gsub(segment, "([A-Za-z0-9._%-~]+)", "")
if tmp ~= "" then
return false
end
Expand Down
45 changes: 45 additions & 0 deletions spec/cases/uri_char_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
before_each(function()
lor = _G.lor
app = lor({
debug = false
})
Request = _G.request
Response = _G.response
req = Request:new()
res = Response:new()

flag = 0
end)

after_each(function()
lor = nil
app = nil
Request = nil
Response = nil
req = nil
res = nil
match = nil
end)

describe("uri should support `-`", function()
it("test case 1", function()
req.path = "/a-b-c"
req.method = "get"
app:get("/a-b-c", function(req, res, next)
flag = 1
end)
app:handle(req, res)
assert.is.equals(1, flag)
end)

it("test case 2", function()
req.path = "/a_-b-/cde/-f"
req.method = "get"
app:get("/a_-b-/cde/-f", function(req, res, next)
flag = 2
end)
app:handle(req, res)
assert.is.equals(2, flag)
end)

end)

0 comments on commit ff6ec83

Please sign in to comment.