Skip to content

Commit

Permalink
don't put extra ? at end of url with empty query params in url_for
Browse files Browse the repository at this point in the history
  • Loading branch information
leafo committed Jun 5, 2015
1 parent db8626b commit 959b223
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lapis/router.moon
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ class Router
if query
if type(query) == "table"
query = encode_query_string query
path ..= "?" .. query

if query != ""
path ..= "?" .. query
path

resolve: (route, ...) =>
Expand Down
4 changes: 4 additions & 0 deletions spec/routes_spec.moon
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ describe "named routes", ->
url = r\url_for "profile", { name: "adam" }, "required"
assert.same "/profile/adam?required", url

it "generates url with empty query params", ->
url = r\url_for "profile", { name: "adam" }, {}
assert.same "/profile/adam", url

it "should create param from object", ->
user = {
url_key: (route_name, param_name) =>
Expand Down

0 comments on commit 959b223

Please sign in to comment.