Skip to content

Commit

Permalink
add manual checks for common-known extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
sfomuseumbot committed Sep 3, 2024
1 parent 6bbd3b9 commit 92698e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
1 change: 0 additions & 1 deletion catalog/catalog.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
// package catalog provides methods for creating lookup tables of tilepack.MbtilesReader instances.
package catalog

22 changes: 17 additions & 5 deletions tile/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,25 @@ func (p *SimpleTileParser) Parse(path string) (*TileRequest, error) {
layer := match[1]
ext := match[5]

t := mimetypes.TypesByExtension(ext)
var content_type string

if len(t) == 0 {
return nil, fmt.Errorf("Unsupported extension '%s'", ext)
}
switch ext {
case "mvt":
content_type = "application/vnd.mapbox-vector-tile"
case "jpg", "jpeg":
content_type = "image/jpeg"
case "png":
content_type = "image/png"
default:

t := mimetypes.TypesByExtension(ext)

content_type := t[0]
if len(t) == 0 {
return nil, fmt.Errorf("Unsupported extension '%s'", ext)
}

content_type = t[0]
}

z, _ := strconv.ParseUint(match[2], 10, 32)
x, _ := strconv.ParseUint(match[3], 10, 32)
Expand Down

0 comments on commit 92698e5

Please sign in to comment.