mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-17 16:38:18 +00:00
feature: client: sw: migrate to ESM
This commit is contained in:
parent
54c89e52f8
commit
27a52d33d0
7 changed files with 19 additions and 15 deletions
|
|
@ -285,10 +285,12 @@ function setUrl(req, res, next) {
|
|||
|
||||
function setSW(req, res, next) {
|
||||
const {url} = req;
|
||||
const isSW = /^\/sw\.js(\.map)?$/.test(url);
|
||||
const isSW = /^\/sw\.[mc]?js(\.map)?$/.test(url);
|
||||
|
||||
if (isSW)
|
||||
if (isSW) {
|
||||
const url = req.url.replace(/[cm]js/, 'js');
|
||||
req.url = replaceDist(`/dist${url}`);
|
||||
}
|
||||
|
||||
next();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ test('cloudcmd: getIndexPath: development', (t) => {
|
|||
});
|
||||
|
||||
test('cloudcmd: sw', async (t) => {
|
||||
const {status} = await request.get('/sw.js');
|
||||
const {status} = await request.get('/sw.mjs');
|
||||
|
||||
t.equal(status, 200, 'should return sw');
|
||||
t.end();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue