From 91b7bc01cbfc71872cb69811e583ca71e9036a26 Mon Sep 17 00:00:00 2001 From: guybedford Date: Sun, 6 Sep 2015 13:30:46 +0200 Subject: [PATCH] corrected fix for #751 --- lib/cjs.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/cjs.js b/lib/cjs.js index 446dec51..17e5d6c7 100644 --- a/lib/cjs.js +++ b/lib/cjs.js @@ -38,7 +38,7 @@ } if (typeof window != 'undefined' && typeof document != 'undefined' && window.location) - var windowOrigin = location.protocol + '//' + (location.protocol == 'file:' && location.hostname[0] != '/' ? '/' : '') + location.hostname + (location.port ? ':' + location.port : ''); + var windowOrigin = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : ''); hookConstructor(function(constructor) { return function() { @@ -91,11 +91,7 @@ dirname.pop(); dirname = dirname.join('/'); - if (windowOrigin && address.substr(0, windowOrigin.length) === windowOrigin) { - address = address.substr(windowOrigin.length); - dirname = dirname.substr(windowOrigin.length); - } - else if (address.substr(0, 8) == 'file:///') { + if (address.substr(0, 8) == 'file:///') { address = address.substr(7); dirname = dirname.substr(7); @@ -105,6 +101,10 @@ dirname = dirname.substr(1); } } + else if (windowOrigin && address.substr(0, windowOrigin.length) === windowOrigin) { + address = address.substr(windowOrigin.length); + dirname = dirname.substr(windowOrigin.length); + } // disable AMD detection var define = __global.define;