Skip to content

Commit

Permalink
Fixed bug with generation of asset URL when running server on MS Wind…
Browse files Browse the repository at this point in the history
…ows.

it used windows specific path separator \ which is incorrect for HTTP protocol, now is using / on any OS.
  • Loading branch information
Mart-Bogdan committed Mar 6, 2014
1 parent b5eb5ef commit ebdfc63
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/template/helpers/index.js
Expand Up @@ -27,7 +27,8 @@ _getAssetPath = function (assetType, src) {
var host
, basePath
, hasProto = /^http:\/\/|^https:\/\/|^data:/
, isAbs;
, isAbs
, assetPath;

// Does not handle exotic protocols like SPDY, or file:// URLs
isAbs = hasProto.test(src) || utils.file.isAbsolute(src);
Expand All @@ -40,7 +41,12 @@ _getAssetPath = function (assetType, src) {

// Include poss. extra leading slash in path.join to ensure
// there's at least one
return host + path.join('/', basePath, assetType, src);
assetPath = host + path.join('/', basePath, assetType, src);

// If we are running server on MS Windows it generates asset paths \ instead of /
// some browsers (for example FF 27.0.1) is sending this symbols as %5C in GET request
// which results in 404 from server, but / is usable on any OS.
return process.platform === 'win32' ? assetPath.replace(/\\/g, '/') : assetPath;
};


Expand Down

0 comments on commit ebdfc63

Please sign in to comment.