Skip to content

Commit 28840da

Browse files
committed
91 Fix problem with escaped underscores
1 parent 394aa7e commit 28840da

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lua/gx/handlers/url.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ function M.handle(mode, line, _)
1818
pattern = "([a-zA-Z%d_/%-%.~@\\+#]+%.[a-zA-Z_/%%%-%.~@\\+#=?&:]+)"
1919
url = helper.find(line, mode, pattern)
2020
if url then
21-
return "https://" .. url
21+
url = "https://" .. url
2222
end
2323
end
2424

25-
return url
25+
if not url then
26+
return
27+
end
28+
29+
return url:gsub("\\([%p])", "%1")
2630
end
2731

2832
return M

test/spec/gx/handlers/url_spec.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ describe("url_parser_does_work", function()
3737
"http://localhost:8080/backend/swagger-ui/#/project-controller",
3838
handler.handle("v", "http://localhost:8080/backend/swagger-ui/#/project-controller")
3939
)
40+
assert.equals(
41+
"https://golang-jwt.github.io/jwt/usage/signing_methods/#signing-methods-and-key-types",
42+
handler.handle("v", "https://golang-jwt.github.io/jwt/usage/signing\\_methods/#signing-methods-and-key-types")
43+
)
4044
end)
4145

4246
it("urls in python", function()

0 commit comments

Comments
 (0)