diff options
| author | Chris Lu <chris.lu@gmail.com> | 2013-07-13 23:46:12 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2013-07-13 23:46:12 -0700 |
| commit | c6bd4e656edaf92c8a2e44f196db156d99f96f20 (patch) | |
| tree | 84e5386f669e528bec5d2df09c99aa1959555ea4 | |
| parent | de368ef3c3e27c89cfd52a21e1103c40df1a62f2 (diff) | |
| download | seaweedfs-c6bd4e656edaf92c8a2e44f196db156d99f96f20.tar.xz seaweedfs-c6bd4e656edaf92c8a2e44f196db156d99f96f20.zip | |
add support for http://localhost:8080/vid/key_cookie
or
http://localhost:8080/vid/key_cookie.txt
| -rw-r--r-- | go/weed/volume.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/go/weed/volume.go b/go/weed/volume.go index 8871fe42d..dbc0ee547 100644 --- a/go/weed/volume.go +++ b/go/weed/volume.go @@ -266,11 +266,20 @@ func DeleteHandler(w http.ResponseWriter, r *http.Request) { } func parseURLPath(path string) (vid, fid, filename, ext string) { - if strings.Count(path, "/") == 3 { + switch strings.Count(path, "/") { + case 3: parts := strings.Split(path, "/") vid, fid, filename = parts[1], parts[2], parts[3] ext = filepath.Ext(filename) - } else { + case 2: + parts := strings.Split(path, "/") + vid, fid = parts[1], parts[2] + dotIndex := strings.LastIndex(fid, ".") + if dotIndex > 0 { + ext = fid[dotIndex:] + fid = fid[0:dotIndex] + } + default: sepIndex := strings.LastIndex(path, "/") commaIndex := strings.LastIndex(path[sepIndex:], ",") if commaIndex <= 0 { |
