X Tutup
Skip to content

replace url\match in nginx.moon#498

Merged
leafo merged 1 commit intoleafo:masterfrom
catesq:master
Dec 14, 2016
Merged

replace url\match in nginx.moon#498
leafo merged 1 commit intoleafo:masterfrom
catesq:master

Conversation

@catesq
Copy link
Contributor

@catesq catesq commented Dec 14, 2016

Corrected fix for #490

@leafo
Copy link
Owner

leafo commented Dec 14, 2016

Nice find, anchoring to the start with ^ should work as well.

@leafo leafo merged commit ce92fb7 into leafo:master Dec 14, 2016
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup