19 lines
459 B
Go
19 lines
459 B
Go
|
|
package storage
|
||
|
|
|
||
|
|
import "strings"
|
||
|
|
|
||
|
|
const AvatarKeyPrefix = "avatars/"
|
||
|
|
|
||
|
|
// IsPublicAssetKey reports whether an object key may be served without auth.
|
||
|
|
func IsPublicAssetKey(key string) bool {
|
||
|
|
key = strings.TrimSpace(key)
|
||
|
|
if key == "" {
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
if strings.Contains(key, "..") {
|
||
|
|
return false
|
||
|
|
}
|
||
|
|
return strings.HasPrefix(key, PublishAttachmentKeyPrefix) ||
|
||
|
|
strings.HasPrefix(key, AvatarKeyPrefix) ||
|
||
|
|
strings.HasPrefix(key, EphemeralKeyPrefix)
|
||
|
|
}
|