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
8 changes: 6 additions & 2 deletions lua/gx/handlers/url.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ function M.handle(mode, line, _)
pattern = "([a-zA-Z%d_/%-%.~@\\+#]+%.[a-zA-Z_/%%%-%.~@\\+#=?&:]+)"
url = helper.find(line, mode, pattern)
if url then
return "https://" .. url
url = "https://" .. url
end
end

return url
if not url then
return
end

return url:gsub("\\([%p])", "%1")
end

return M
7 changes: 7 additions & 0 deletions test/spec/gx/handlers/url_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ describe("url_parser_does_work", function()
"http://localhost:8080/backend/swagger-ui/#/project-controller",
handler.handle("v", "http://localhost:8080/backend/swagger-ui/#/project-controller")
)
assert.equals(
"https://golang-jwt.github.io/jwt/usage/signing_methods/#signing-methods-and-key-types",
handler.handle(
"v",
"https://golang-jwt.github.io/jwt/usage/signing\\_methods/#signing-methods-and-key-types"
)
)
end)

it("urls in python", function()
Expand Down