Skip to content

Commit 2956cda

Browse files
committed
Replaced private method getContentTypeExtension with public mapFileToUrl
1 parent baec665 commit 2956cda

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

lib/handlers/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function handler (req, res, next) {
8383
rootPath: ldp.root,
8484
includeHost: ldp.multiuser
8585
})
86-
contentType = mapper._getContentTypeByExtension(path)
86+
contentType = mapper.mapFileToUrl({ path }).contentType
8787
res.setHeader('Content-Type', contentType)
8888
res.status(200).send('OK')
8989
return next()

lib/resource-mapper.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ class ResourceMapper {
5656
}
5757

5858
// Maps a given server file to a URL
59-
async mapFileToUrl ({ path, hostname }) {
60-
// Determine the URL by chopping off everything after the dollar sign
59+
mapFileToUrl ({ path, hostname }) {
6160
const pathname = this._removeDollarExtension(path.substring(this._rootPath.length))
6261
const url = `${this.getBaseUrl(hostname)}${encodeURI(pathname)}`
63-
return { url, contentType: this._getContentTypeByExtension(path) }
62+
const contentType = this._getContentTypeByExtension(path)
63+
return { url, contentType }
6464
}
6565

6666
// Gets the base file path for the given hostname

test/unit/legacy-resource-mapper-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ function mapsUrl (it, mapper, label, options, expected) {
239239
}
240240

241241
function mapsFile (it, mapper, label, options, expected) {
242-
it(`maps ${label}`, async () => {
243-
const actual = await mapper.mapFileToUrl(options)
242+
it(`maps ${label}`, () => {
243+
const actual = mapper.mapFileToUrl(options)
244244
expect(actual).to.deep.equal(expected)
245245
})
246246
}

test/unit/resource-mapper-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,8 @@ function mapsUrl (it, mapper, label, options, files, expected) {
438438
}
439439

440440
function mapsFile (it, mapper, label, options, expected) {
441-
it(`maps ${label}`, async () => {
442-
const actual = await mapper.mapFileToUrl(options)
441+
it(`maps ${label}`, () => {
442+
const actual = mapper.mapFileToUrl(options)
443443
expect(actual).to.deep.equal(expected)
444444
})
445445
}

0 commit comments

Comments
 (0)