Comparing version 2023.12.18 to 2023.12.19
@@ -174,2 +174,12 @@ module.exports = function init(____0) { | ||
fsm.off = function (path) { | ||
if (path && Array.isArray(path)) { | ||
path.forEach((p) => { | ||
fsm.off(p); | ||
}); | ||
return; | ||
} | ||
if (typeof path === 'object') { | ||
path = path.path; | ||
} | ||
path = fsm.getFilePath(path); | ||
if (path && typeof path == 'string') { | ||
@@ -181,6 +191,2 @@ for (let i = fsm.list.length; i--; ) { | ||
} | ||
} else if (path && Array.isArray(path)) { | ||
path.forEach((p) => { | ||
fsm.off(p); | ||
}); | ||
} | ||
@@ -250,3 +256,3 @@ }; | ||
}; | ||
fsm.readFile = function (path, callback) { | ||
@@ -352,3 +358,3 @@ path = fsm.getFilePath(path); | ||
fsm.isImage = function (extname) { | ||
if (extname == 'png' || extname == 'jpg' || extname == 'jpeg' || extname == 'bmp' || extname == 'ico' || extname == 'webp') { | ||
if (extname.contains('png|jpg|jpeg|bmp|ico|webp|gif')) { | ||
return true; | ||
@@ -367,2 +373,3 @@ } | ||
let path = name; | ||
if (!____0.isFileExistsSync(path)) { | ||
@@ -369,0 +376,0 @@ path = ____0.path.join(____0.dir, extname, name); |
@@ -38,3 +38,2 @@ module.exports = function init(____0) { | ||
route.path = route.path || ''; | ||
let encode = ____0.getFileEncode(route.path); | ||
@@ -67,2 +66,4 @@ // let hash = req.content ? ____0.x0md50x(req.content) : ____0.x0md50x(''); | ||
let encode = ____0.getFileEncode(route.path); | ||
if (route.path.endsWith('.css')) { | ||
@@ -307,14 +308,25 @@ res.set(____0.strings[7], 'text/css'); | ||
} | ||
if (!r.name.startsWith('/')) { | ||
r.name = '/' + r.name; | ||
} | ||
for (let i = _0xrrxo.list.length; i--; ) { | ||
let r0 = _0xrrxo.list[i]; | ||
if (r.name && r.method && r0.name.like(r.name) && r0.method.like(r.method)) { | ||
let oldRoute = _0xrrxo.list[i]; | ||
if (r.name && r.method && oldRoute.name.like(r.name) && oldRoute.method.like(r.method)) { | ||
_0xrrxo.list.splice(i, 1); | ||
____0.fsm.off(r0.path); | ||
} else if (r.name && r0.name.like(r.name)) { | ||
____0.fsm.off(oldRoute.path); | ||
} else if (r.name && r.method && oldRoute.nameRaw.like(r.name) && oldRoute.method.like(r.method)) { | ||
_0xrrxo.list.splice(i, 1); | ||
____0.fsm.off('*' + r0.name.replace('/', '') + '*'); | ||
____0.fsm.off(r0.path); | ||
} else if (r.method && r0.method.like(r.method)) { | ||
____0.fsm.off(oldRoute.path); | ||
} else if (r.name && oldRoute.name.like(r.name)) { | ||
_0xrrxo.list.splice(i, 1); | ||
____0.fsm.off(r0.path); | ||
____0.fsm.off('*' + oldRoute.name.replace('/', '') + '*'); | ||
____0.fsm.off(oldRoute.path); | ||
} else if (r.name && oldRoute.nameRaw.like(r.name)) { | ||
_0xrrxo.list.splice(i, 1); | ||
____0.fsm.off('*' + oldRoute.name.replace('/', '') + '*'); | ||
____0.fsm.off(oldRoute.path); | ||
} else if (r.method && oldRoute.method.like(r.method)) { | ||
_0xrrxo.list.splice(i, 1); | ||
____0.fsm.off(oldRoute.path); | ||
} | ||
@@ -342,3 +354,3 @@ } | ||
route.name = r.toLowerCase(); | ||
route.name0 = r; | ||
route.nameRaw = r; | ||
route.public = ____0.options.public || false; | ||
@@ -367,3 +379,3 @@ route.method = 'GET'; | ||
route.name = r.name.toLowerCase(); | ||
route.name0 = r.name; | ||
route.nameRaw = r.name; | ||
route.public = r.public ?? (____0.options.public || false); | ||
@@ -404,10 +416,10 @@ route.method = r.method || 'GET'; | ||
route.name = '/' + route.name; | ||
route.name0 = '/' + route.name0; | ||
route.nameRaw = '/' + route.nameRaw; | ||
} | ||
route.name = route.name.replace('//', '/'); | ||
route.name0 = route.name0.replace('//', '/'); | ||
route.nameRaw = route.nameRaw.replace('//', '/'); | ||
let arr = route.name.split('/'); | ||
let arr0 = route.name0.split('/'); | ||
let arr0 = route.nameRaw.split('/'); | ||
@@ -421,3 +433,3 @@ for (var i = 0; i < arr.length; i++) { | ||
let name = s.replace(':', ''); | ||
let name0 = s0.replace(':', ''); | ||
let nameRaw = s0.replace(':', ''); | ||
@@ -429,6 +441,6 @@ route.map.push({ | ||
}); | ||
if (name !== name0) { | ||
if (name !== nameRaw) { | ||
route.map.push({ | ||
index: i, | ||
name: name0, | ||
name: nameRaw, | ||
isLower: !0, | ||
@@ -465,3 +477,3 @@ }); | ||
_0xrrxo.list.push(route); | ||
} else if (index > -1 && !route.overwrite) { | ||
} else if (!route.overwrite) { | ||
if (route.name.like('*api/*')) { | ||
@@ -879,4 +891,11 @@ ____0.log('[ Duplicate API ] ' + route.name); | ||
res.html = res.render = function (name, _data, options) { | ||
____0.fsm.getContent(name, (content) => { | ||
res.html = res.render = function (file, _data = null, options = {}) { | ||
let filePath = ''; | ||
if (typeof file === 'object') { | ||
filePath = file.path; | ||
options = { ...options, ...file }; | ||
} else { | ||
filePath = file; | ||
} | ||
____0.fsm.getContent(filePath, (content) => { | ||
if (!content) { | ||
@@ -890,6 +909,4 @@ if (_data && _data.html) { | ||
options = options || {}; | ||
req.content = content; | ||
req.data = { ...req.data, ..._data }; | ||
req.route = req.route || {}; | ||
req.route = { ...req.route, ...options }; | ||
@@ -906,3 +923,3 @@ if (req.route.parser) { | ||
if (name.endsWith('.css')) { | ||
if (filePath.endsWith('.css')) { | ||
res.set(____0.strings[7], 'text/css'); | ||
@@ -912,3 +929,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.js')) { | ||
} else if (filePath.endsWith('.js')) { | ||
res.set(____0.strings[7], 'application/javascript'); | ||
@@ -918,3 +935,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.html')) { | ||
} else if (filePath.endsWith('.html')) { | ||
res.set(____0.strings[7], 'text/html'); | ||
@@ -924,3 +941,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.txt')) { | ||
} else if (filePath.endsWith('.txt')) { | ||
res.set(____0.strings[7], 'text/plain'); | ||
@@ -930,3 +947,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.json')) { | ||
} else if (filePath.endsWith('.json')) { | ||
res.set(____0.strings[7], 'application/json'); | ||
@@ -936,3 +953,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.xml')) { | ||
} else if (filePath.endsWith('.xml')) { | ||
res.set(____0.strings[7], 'text/xml'); | ||
@@ -942,3 +959,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.woff2')) { | ||
} else if (filePath.endsWith('.woff2')) { | ||
res.set(____0.strings[7], 'application/font-woff2'); | ||
@@ -948,3 +965,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.woff')) { | ||
} else if (filePath.endsWith('.woff')) { | ||
res.set(____0.strings[7], 'application/font-woff'); | ||
@@ -954,3 +971,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.ttf')) { | ||
} else if (filePath.endsWith('.ttf')) { | ||
res.set(____0.strings[7], 'application/font-ttf'); | ||
@@ -960,3 +977,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.svg')) { | ||
} else if (filePath.endsWith('.svg')) { | ||
res.set(____0.strings[7], 'application/font-svg'); | ||
@@ -966,3 +983,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.otf')) { | ||
} else if (filePath.endsWith('.otf')) { | ||
res.set(____0.strings[7], 'application/font-otf'); | ||
@@ -972,3 +989,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.eot')) { | ||
} else if (filePath.endsWith('.eot')) { | ||
res.set(____0.strings[7], 'application/font-eot'); | ||
@@ -978,3 +995,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.gif')) { | ||
} else if (filePath.endsWith('.gif')) { | ||
res.set(____0.strings[7], 'image/gif'); | ||
@@ -984,3 +1001,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.png')) { | ||
} else if (filePath.endsWith('.png')) { | ||
res.set(____0.strings[7], 'image/png'); | ||
@@ -990,3 +1007,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.jpg')) { | ||
} else if (filePath.endsWith('.jpg')) { | ||
res.set(____0.strings[7], 'image/jpg'); | ||
@@ -996,3 +1013,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.jpeg')) { | ||
} else if (filePath.endsWith('.jpeg')) { | ||
res.set(____0.strings[7], 'image/jpeg'); | ||
@@ -1002,3 +1019,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.ico')) { | ||
} else if (filePath.endsWith('.ico')) { | ||
res.set(____0.strings[7], 'image/ico'); | ||
@@ -1008,3 +1025,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.bmp')) { | ||
} else if (filePath.endsWith('.bmp')) { | ||
res.set(____0.strings[7], 'image/bmp'); | ||
@@ -1014,3 +1031,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
} else if (name.endsWith('.webp')) { | ||
} else if (filePath.endsWith('.webp')) { | ||
res.set(____0.strings[7], 'image/webp'); | ||
@@ -1021,3 +1038,3 @@ if (____0.options.cache.enabled && req.route.cache) { | ||
} | ||
res.end(req.content, ____0.getFileEncode(name)); | ||
res.end(req.content, ____0.getFileEncode(filePath)); | ||
}); | ||
@@ -1181,4 +1198,10 @@ }; | ||
let map = req.route.map[i]; | ||
req.params[map.name] = decodeURIComponent(req.urlParser.arr[map.index].replace(/\+/g, ' ')); | ||
req.paramsRaw[map.name] = req.urlParserRaw.arr[map.index]; | ||
if (typeof req.urlParser.arr[map.index] === 'string') { | ||
try { | ||
req.params[map.name] = decodeURIComponent(req.urlParser.arr[map.index].replace(/\+/g, ' ')); | ||
} catch (error) { | ||
req.params[map.name] = req.urlParser.arr[map.index].replace(/\+/g, ' '); | ||
} | ||
req.paramsRaw[map.name] = req.urlParserRaw.arr[map.index]; | ||
} | ||
} | ||
@@ -1285,3 +1308,3 @@ | ||
if (____0.options.help) { | ||
res.set('help-eror-message', 'unhandled route root ' + req.urlParser.pathname); | ||
res.set('help-eror-message', 'unhandled route root : ' + req.urlParser.pathname); | ||
} | ||
@@ -1293,3 +1316,3 @@ res.htmlContent("<h1 align='center'>Base Route / Not Set</h1>"); | ||
if (____0.options.help) { | ||
res.set('help-eror-message', 'unhandled route help' + req.urlParser.pathname); | ||
res.set('help-eror-message', 'unhandled route help : ' + req.urlParser.pathname); | ||
} | ||
@@ -1304,3 +1327,3 @@ | ||
____0.handleNotRoute = function (req, res) { | ||
res.set('help-eror-message', 'unhandled route fn' + req.urlParser.pathname); | ||
res.set('help-eror-message', 'unhandled route fn : ' + req.urlParser.pathname); | ||
res.status(404).end(); | ||
@@ -1307,0 +1330,0 @@ }; |
@@ -43,2 +43,3 @@ exports = module.exports = setOptions; | ||
theme: 'default', | ||
public : false, | ||
help: !1, | ||
@@ -45,0 +46,0 @@ stdin: !0, |
{ | ||
"name": "isite", | ||
"version": "2023.12.18", | ||
"version": "2023.12.19", | ||
"description": "Create Secure Multi-Language Web Site [Fast and Easy] ", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19135443
80444