File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ class ResourceMapper {
4444 // Determine the path of an existing file
4545 } else {
4646 // Read all files in the corresponding folder
47- const filename = / [ ^ / ] * $ / . exec ( pathname ) [ 0 ]
47+ const filename = pathname . substr ( pathname . lastIndexOf ( '/' ) + 1 )
4848 const folder = `${ basePath } ${ pathname . substr ( 0 , pathname . length - filename . length ) } `
4949 const files = await this . _readdir ( folder )
5050
@@ -81,12 +81,14 @@ class ResourceMapper {
8181
8282// Removes a possible trailing slash from a path
8383function removeTrailingSlash ( path ) {
84- return path ? path . replace ( / \/ + $ / , '' ) : ''
84+ const lastPos = path . length - 1
85+ return lastPos < 0 || path [ lastPos ] !== '/' ? path : path . substr ( 0 , lastPos )
8586}
8687
8788// Removes everything beyond the dollar sign from a path
8889function removeDollarExtension ( path ) {
89- return path . replace ( / \$ .* / , '' )
90+ const dollarPos = path . lastIndexOf ( '$' )
91+ return dollarPos < 0 ? path : path . substr ( 0 , dollarPos )
9092}
9193
9294// Gets the expected content type based on the extension of the path
You can’t perform that action at this time.
0 commit comments