Skip to content

Commit 0fb4548

Browse files
authored
only map mimeType part of contentType (#1579)
1 parent ad5d833 commit 0fb4548

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/resource-mapper.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ class ResourceMapper {
9191
// Maps the request for a given resource and representation format to a server file
9292
// Will look for an index file if a folder is given and searchIndex is true
9393
async mapUrlToFile ({ url, contentType, createIfNotExists, searchIndex = true }) {
94+
// map contentType to mimeType part
95+
contentType = contentType ? contentType.replace(/\s*;.*/, '') : ''
9496
// Parse the URL and find the base file path
9597
const { pathname, hostname } = this._parseUrl(url)
9698
const filePath = this.resolveFilePath(hostname, decodeURIComponent(pathname))

test/unit/resource-mapper-test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ describe('ResourceMapper', () => {
5252
contentType: 'text/html'
5353
})
5454

55+
itMapsUrl(mapper, 'a Url and a contentType with charset',
56+
{
57+
url: 'http://localhost/space/foo.txt',
58+
contentType: 'text/plain; charset=utf-8',
59+
createIfNotExists: true
60+
},
61+
{
62+
path: `${rootPath}space/foo.txt`,
63+
contentType: 'text/plain'
64+
})
65+
5566
// Additional PUT cases
5667

5768
itMapsUrl(mapper, 'a URL without content type',

0 commit comments

Comments
 (0)