Software /
code /
prosody
Comparison
net/http/parser.lua @ 5207:c5edb08fc7cb
net.http.parser: Collapse multiple consecutive slashes in a path to a single slash
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 29 Nov 2012 07:38:00 +0500 |
parent | 4910:e5ec60dfb202 |
child | 5222:61c47d26481d |
comparison
equal
deleted
inserted
replaced
5204:0b4f680ea116 | 5207:c5edb08fc7cb |
---|---|
3 local assert = assert; | 3 local assert = assert; |
4 local url_parse = require "socket.url".parse; | 4 local url_parse = require "socket.url".parse; |
5 local urldecode = require "net.http".urldecode; | 5 local urldecode = require "net.http".urldecode; |
6 | 6 |
7 local function preprocess_path(path) | 7 local function preprocess_path(path) |
8 path = urldecode(path); | 8 path = urldecode((path:gsub("//+". "/"))); |
9 if path:sub(1,1) ~= "/" then | 9 if path:sub(1,1) ~= "/" then |
10 path = "/"..path; | 10 path = "/"..path; |
11 end | 11 end |
12 local level = 0; | 12 local level = 0; |
13 for component in path:gmatch("([^/]+)/") do | 13 for component in path:gmatch("([^/]+)/") do |