nw.js
nw.js copied to clipboard
RegExp variable seems changed its type after passing to another function
- [x] Bug Report
as the following codes show, I pass the variable /^/test1(.*)?$/ to function unless,when I run those code in nodejs(v16.9.1) , it works fine .when I access /login and /test1 , the console doesn't log 'customMiddleware called'. which means variable vv matchs the string '/test1' while '/login' matchs the string '/login'.
then I put those code in a html and run it in nwjs , when I access /login, it works fun, the console doesn't log anything. but when I access /test1, the console output 'customMiddleware called', which means vv didn't match the string '/test1'. I add some console code in function unless, it showed that (vv instanceof RexExp) is false and typeof vv is 'object'.
I run it in nwjs v0.70.1 and v0.90.0 , both not work.
-
[x] Successfully reproduced against the latest version of NW.js? YES
-
Operating System:windows 10
-
NW.js Version:nwjs-sdk-v0.70.1-win-x64 and nwjs-sdk-v0.90.0-win-x64
-
Code snippet: ` const express=require('express') const express_unless_1 = require("express-unless"); const app=express()
const customMiddleware = function (req, res, next) { console.log('customMiddleware called'); next(); }; customMiddleware.unless=express_unless_1.unless;
const vv = /^/test1(.*)?$/
console.log('vv is regexp:',vv instanceof RegExp)
app.use(customMiddleware.unless({
path: ["/login",vv]
}))
app.get('/test',(req,res)=>{ res.send('test ') })
app.get('/login',(req,res)=>{ res.send('login ') }) app.listen(3000,()=>{ console.log('app listen 3000') }) `