Skip to content

Commit

Permalink
server: fix virtual file path resolving issue on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Sep 15, 2015
1 parent 68a0493 commit 5ca9f5a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/server/modules/plugin-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ function extend(dest, source){
return dest;
}

function normalizeFilename(filename){
return path.resolve('/' + filename)
// windows issues: cut drive in beginning and replaces `\` to `/`
.replace(/^[a-z]:/i, '')
.replace(/\\/g, '/');
}

module.exports = function(options, pluginOptions){
var ignore;

Expand All @@ -29,7 +36,7 @@ module.exports = function(options, pluginOptions){
var filename =
'/basisjs-tools/plugin:' +
path.basename(path.dirname(pluginOptions.name).replace(/^\.$/, '') || pluginOptions.name) +
path.resolve('/' + filename);
normalizeFilename(filename);
var contentType = mime.lookup(filename, 'text/plain');
var file = {
content: content,
Expand Down

0 comments on commit 5ca9f5a

Please sign in to comment.