X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lapis/nginx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ local ngx_req = {
end,
parsed_url = function(t)
local uri = ngx.var.request_uri
uri = uri:match("(.-)%?") or uri
local pos = uri:find("?")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't find("?", 1, true) be even faster?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also those two lines could be turned into something like `local uri = uri:sub(1, (uri:find("?", 1, true) or 0) -1)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably an insignificant amount, there is no pattern on the single character pattern, so it will still end up matching it literally. Regarding combining the two lines, I don't really see an advantage to making it harder to read

uri = pos and uri:sub(1, pos - 1) or uri
local host_header = ngx.var.http_host
return {
scheme = ngx.var.scheme,
Expand Down
3 changes: 2 additions & 1 deletion lapis/nginx.moon
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ ngx_req = {

parsed_url: (t) ->
uri = ngx.var.request_uri
uri = uri\match("(.-)%?") or uri
pos = uri\find("?")
uri = pos and uri\sub(1, pos-1) or uri
host_header = ngx.var.http_host

{
Expand Down
X Tutup