From 47973be19f453aadfc810a5439a12d48e110984a Mon Sep 17 00:00:00 2001 From: eric thul Date: Mon, 14 Mar 2016 20:35:35 -0400 Subject: Escape path for require Resolves #41 --- src/PursLoader/Loader.purs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/PursLoader/Loader.purs') diff --git a/src/PursLoader/Loader.purs b/src/PursLoader/Loader.purs index 97954f6..acb0993 100644 --- a/src/PursLoader/Loader.purs +++ b/src/PursLoader/Loader.purs @@ -21,6 +21,8 @@ import Data.String.Regex (Regex(), match, noFlags, regex) import Unsafe.Coerce (unsafeCoerce) +import PursLoader.Debug (debug) +import PursLoader.JsStringEscape (jsStringEscape) import PursLoader.LoaderRef ( AsyncCallback() , LoaderRef() @@ -30,8 +32,6 @@ import PursLoader.LoaderRef , addDependency , resourcePath ) - -import PursLoader.Debug (debug) import PursLoader.Path (dirname, joinPath, relative) import PursLoader.Plugin as Plugin @@ -79,13 +79,13 @@ loader ref source = do else moduleExport <<< modulePath <$> name where bundleExport :: String -> String - bundleExport name' = "module.exports = require('" ++ path ++ "')['" ++ name' ++ "'];" + bundleExport name' = "module.exports = require('" ++ jsStringEscape path ++ "')['" ++ name' ++ "'];" where path :: String path = relative resourceDir pluginContext.options.bundleOutput moduleExport :: String -> String - moduleExport path = "module.exports = require('" ++ path ++ "');" + moduleExport path = "module.exports = require('" ++ jsStringEscape path ++ "');" modulePath :: String -> String modulePath = relative resourceDir <<< joinPath pluginContext.options.output -- cgit v1.2.3