Skip to content

Commit

Permalink
fix: ensure bundle asset file URL are properly formed
Browse files Browse the repository at this point in the history
  • Loading branch information
jchip committed Mar 25, 2020
1 parent ee0b34d commit 8d11390
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/subapp-server/lib/setup-hapi-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ async function setupRoutesFromFile(srcDir, server, pluginOpts) {
return h.continue;
});

// in case needed, add full protocol/host/port to dev bundle base URL
topOpts.devBundleBase = subAppUtil.formUrl({
..._.pick(topOpts.devServer, ["protocol", "host", "port"]),
path: "/js/"
path: topOpts.devBundleBase
});

// register routes
Expand Down Expand Up @@ -253,9 +254,10 @@ async function setupRoutesFromDir(server, pluginOpts, fromDir) {
});
}

// in case needed, add full protocol/host/port to dev bundle base URL
topOpts.devBundleBase = subAppUtil.formUrl({
..._.pick(topOpts.devServer, ["protocol", "host", "port"]),
path: "/js/"
path: topOpts.devBundleBase
});

registerRoutes({ routes, topOpts, server });
Expand Down
7 changes: 5 additions & 2 deletions packages/subapp-web/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,13 @@ const utils = {
}
}

const baseFilePath = Path.posix.join(basePath, bundleFile);
if (!cdnBundles[id]) {
cdnBundles[id] = basePath.concat(bundleFile);
// set a simple string
cdnBundles[id] = baseFilePath;
} else {
cdnBundles[id] = [].concat(cdnBundles[id], basePath.concat(bundleFile));
// multiple assets for bundle, set and concat as an array
cdnBundles[id] = [].concat(cdnBundles[id], baseFilePath);
}
});
}
Expand Down

0 comments on commit 8d11390

Please sign in to comment.