aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/main.go b/main.go
index b01e687..8c154e8 100644
--- a/main.go
+++ b/main.go
@@ -183,7 +183,6 @@ func handleThumbs(w http.ResponseWriter, r *http.Request) {
func getSubdirectories(tx *sql.Tx, parent int64) (names []string, err error) {
// TODO: This is like dbCollectStrings(), just needs an argument.
- // TODO: Should this return full paths, or not? Clean it up.
rows, err := tx.Query(
`SELECT name FROM directory WHERE IFNULL(parent, 0) = ?`, parent)
if err != nil {
@@ -282,7 +281,7 @@ func getImagePaths(sha1 string) (paths []string, err error) {
UNION ALL
SELECT d.parent, d.name || '/' || p.path
FROM directory AS d JOIN paths AS p ON d.id = p.parent
- ) SELECT '/' || path FROM paths WHERE parent IS NULL`, sha1)
+ ) SELECT path FROM paths WHERE parent IS NULL`, sha1)
if err != nil {
return nil, err
}
@@ -430,16 +429,15 @@ func idForPath(tx *sql.Tx, path []string, create bool) (int64, error) {
}
func decodeWebPath(path string) []string {
- // Trailing slashes don't provide information.
- path = strings.TrimSuffix(path, "/")
-
// Relative paths could be handled differently,
// but right now, they're assumed to start at the root.
- list := strings.Split(path, "/")
- if len(list) > 0 && list[0] == "" {
- list = list[1:]
+ result := []string{}
+ for _, crumb := range strings.Split(path, "/") {
+ if crumb != "" {
+ result = append(result, crumb)
+ }
}
- return list
+ return result
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -