Skip to content

Commit

Permalink
Update FileIDFromPath to replace slashes with underscores (#24)
Browse files Browse the repository at this point in the history
* Update FileIDFromPath to replace slashes with underscores

* Import strings
  • Loading branch information
vansante authored Mar 25, 2020
1 parent e8031b5 commit d3ffea0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fileid.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import (
"crypto/rand"
"encoding/base64"
"net/url"
"strings"
)

// FileID is a unique descriptor for a file, should be usable in an URL.
type FileID string

// FileIDFromPath creates a usable FileID from a file path
func FileIDFromPath(path string) FileID {
path = strings.ReplaceAll(path, "/", "_")
return FileID(url.PathEscape(path))
}

Expand Down

0 comments on commit d3ffea0

Please # to comment.