Skip to content
Permalink
Browse files
Remove duplicate slashes from an uri path.
Now Req:get(path) returns a path without duplicate slashes.
E.g. uri path "//foo///bar////" becomes "/foo/bar/".

Signed-off-by: Oleg Nemanov <lego12239@yandex.ru>
  • Loading branch information
lego12239 committed Apr 27, 2016
1 parent 3c9b72a commit ba2ba3e7071886d06ab03e49cb8492151ba8c822
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
@@ -136,8 +136,9 @@ get(path, {?MODULE, [_Socket, _Opts, _Method, RawPath, _Version, _Headers]}) ->
undefined ->
{Path0, _, _} = mochiweb_util:urlsplit_path(RawPath),
Path = mochiweb_util:unquote(Path0),
put(?SAVE_PATH, Path),
Path;
Path_n = mochiweb_util:normalize_path(Path),
put(?SAVE_PATH, Path_n),
Path_n;
Cached ->
Cached
end;
@@ -6,7 +6,7 @@ with_server(Transport, ServerFun, ClientFun) ->
mochiweb_test_util:with_server(Transport, ServerFun, ClientFun).

request_test() ->
R = mochiweb_request:new(z, z, "/foo/bar/baz%20wibble+quux?qs=2", z, []),
R = mochiweb_request:new(z, z, "//foo///bar/baz%20wibble+quux?qs=2", z, []),
"/foo/bar/baz wibble quux" = R:get(path),
ok.

0 comments on commit ba2ba3e

Please sign in to comment.