# HG changeset patch # User Matthew Wild # Date 1291123127 0 # Node ID 44f2945d09cfdbfdfa55419b4d0ffbacdfaaf115 # Parent b70f75414c8105dd6550609fdbf7b66137df7929 squish.lua: Support for AutoFetch to use file:// URLs diff -r b70f75414c81 -r 44f2945d09cf squish.lua --- a/squish.lua Tue Nov 09 20:41:21 2010 +0000 +++ b/squish.lua Tue Nov 30 13:18:47 2010 +0000 @@ -225,8 +225,19 @@ print_debug("Packing "..modulename.." ("..path..")..."); local data, err = fetch.filesystem(path); if (not data) and module.url then - print_debug("Fetching: ".. module.url:gsub("%?", module.path)) - data, err = fetch.http(module.url:gsub("%?", module.path)); + local url = module.url:gsub("%?", module.path); + print_debug("Fetching: ".. url) + if url:match("^https?://") then + data, err = fetch.http(url); + elseif url:match("^file://") then + local dataf, dataerr = io.open((url:gsub("^file://", ""))); + if dataf then + data, err = dataf:read("*a"); + dataf:close(); + else + data, err = nil, dataerr; + end + end end if data then f:write("package.preload['", modulename, "'] = (function (...)\n");