Skip to content

Commit 1a4421b

Browse files
Normalize paths for Windows (forward slashes) (#1535)
* Update resource-mapper.js * Create node.js.yml * Delete node.js.yml * Update resource-mapper.js
1 parent ef17223 commit 1a4421b

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/resource-mapper.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const { promisify } = require('util')
66
const { types, extensions } = require('mime-types')
77
const readdir = promisify(fs.readdir)
88
const HTTPError = require('./http-error')
9-
const pathUtil = require('path')
109

1110
/*
1211
* A ResourceMapper maintains the mapping between HTTP URLs and server filenames,
@@ -30,7 +29,7 @@ class ResourceMapper {
3029
overrideTypes = { acl: 'text/turtle', meta: 'text/turtle' }
3130
}) {
3231
this._rootUrl = this._removeTrailingSlash(rootUrl)
33-
this._rootPath = this._removeTrailingSlash(rootPath)
32+
this._rootPath = this._removeTrailingSlash(rootPath).replace(/\\/g, '/')
3433
this._includeHost = includeHost
3534
this._readdir = readdir
3635
this._defaultContentType = defaultContentType
@@ -84,7 +83,7 @@ class ResourceMapper {
8483
// Determine the URL by chopping off everything after the dollar sign
8584
const pathname = this._removeDollarExtension(path)
8685
const url = `${this.resolveUrl(hostname)}${
87-
pathname.split(pathUtil.sep).map((component) => encodeURIComponent(component)).join('/')
86+
pathname.split('/').map((component) => encodeURIComponent(component)).join('/')
8887
}`
8988
return { url, contentType: this._getContentTypeFromExtension(path) }
9089
}

0 commit comments

Comments
 (0)