Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/middleware/mapped.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function(mappedPaths) {

function mapUrl(urlPath) {
var urlObj = url.parse(urlPath.toString())
urlObj.pathname = mappedPaths[urlObj.pathname] || urlPath
urlObj.pathname = mappedPaths[urlObj.pathname] || urlObj.pathname
return url.format(urlObj)
}

Expand Down
12 changes: 10 additions & 2 deletions test/mapped-versionator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,21 @@ describe('versionator', function() {
mapped.modifyMap({ '/js/test.js': '/js/OTHERHASH/test.js' })
mapped.versionPath('/js/test.js').should.eql('/js/OTHERHASH/test.js')
})
it('strings without a "/" will be left unchanged', function() {
it('strings without a "/" will be encoded correctly', function() {
var mapped = versionator.createMapped({
'/js/test.js': '/js/HASH/test.js'
})
mapped
.versionPath('Hello this is an odd path')
.should.eql('Hello this is an odd path')
.should.eql('Hello%20this%20is%20an%20odd%20path')
})
it('strings with a hash and no match will be encoded correctly', function() {
var mapped = versionator.createMapped({
'/js/test.js': '/js/HASH/test.js'
})
mapped
.versionPath('/test/ing#hashparam')
.should.eql('/test/ing#hashparam')
})

it('should convert all URLs in an array', function() {
Expand Down