core: Allow dots in MIME file types

As reported in https://github.com/tus/tusd/issues/304
This commit is contained in:
Marius 2019-09-05 19:45:43 +02:00
parent f1fe5e2603
commit 852b6fa01d
2 changed files with 5 additions and 5 deletions

View File

@ -134,8 +134,8 @@ func TestGet(t *testing.T) {
store.EXPECT().GetInfo("yes").Return(FileInfo{ store.EXPECT().GetInfo("yes").Return(FileInfo{
Offset: 0, Offset: 0,
MetaData: map[string]string{ MetaData: map[string]string{
"filetype": "text/html", "filetype": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"filename": "invoice.html", "filename": "invoice.docx",
}, },
}, nil) }, nil)
@ -148,8 +148,8 @@ func TestGet(t *testing.T) {
URL: "yes", URL: "yes",
ResHeader: map[string]string{ ResHeader: map[string]string{
"Content-Length": "0", "Content-Length": "0",
"Content-Type": "text/html", "Content-Type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"Content-Disposition": `attachment;filename="invoice.html"`, "Content-Disposition": `attachment;filename="invoice.docx"`,
}, },
Code: http.StatusNoContent, Code: http.StatusNoContent,
ResBody: "", ResBody: "",

View File

@ -24,7 +24,7 @@ var (
reExtractFileID = regexp.MustCompile(`([^/]+)\/?$`) reExtractFileID = regexp.MustCompile(`([^/]+)\/?$`)
reForwardedHost = regexp.MustCompile(`host=([^,]+)`) reForwardedHost = regexp.MustCompile(`host=([^,]+)`)
reForwardedProto = regexp.MustCompile(`proto=(https?)`) reForwardedProto = regexp.MustCompile(`proto=(https?)`)
reMimeType = regexp.MustCompile(`^[a-z]+\/[a-z\-\+]+$`) reMimeType = regexp.MustCompile(`^[a-z]+\/[a-z\-\+\.]+$`)
) )
// HTTPError represents an error with an additional status code attached // HTTPError represents an error with an additional status code attached