« first day (2780 days earlier)      last day (1337 days later) » 

 
5 hours later…
6:57 AM
I don't know How to handle CORS error in Express JS.
my CORS function is here
`
CORS = require('cors');
corsOptionsDelegateForApis = function (req, callback) {
var fl=false;


var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress,org=req.headers.origin||req.headers.referer;
if("file://" == org) org = req.headers.host;
for(var k in _ALLOW_DOM){
if( (org && org.indexOf(_ALLOW_DOM[k]) != -1 ) || ip.indexOf(_ALLOW_DOM[k]) != -1)
{
fl=true; break;
}
}

if(!fl)
{
callback(new Error('ERROR'));
 
1 message moved from JavaScript
 
 
3 hours later…
9:37 AM
I want something like this (is only way which working in my case)
let foo = (() => {
let bar = {x:1};
bar.x = 2;
return bar;
})()
but I find function ugly
 
1 message moved from JavaScript
 
I want something like this (is only way which working in my case)
let foo = (() => {
let bar = {x:1};
bar.x = 2;
return bar;
})()
but I find function ugly
 
1 message moved from JavaScript
 
 
1 hour later…
 
7 hours later…
6:30 PM
This is the code
```
self.addEventListener('fetch', (e) => {
if (!(e.request.url.indexOf('http') === 0) || e.request.method !== 'GET') {
return;
}

ignoreResources.forEach((resource) => {
if (e.request.url.indexOf(resource) !== -1) return;
});

e.respondWith(
caches.match(e.request).then((cacheRes) => {
return (
cacheRes ||
fetch(e.request).then(async (fetchRes) => {
return await caches.open(dynamicCacheName).then((cache) => {
cache.put(e.request.url, fetchRes.clone());
return fetchRes;
});
})
);
 
1 message moved from JavaScript
 
7:15 PM
```
function myFunction(){
var value = { word: "abc!!??def" };

value.word = removeSpecialCharacters(value.word);

console.log(value.word);
}

function removeSpecialCharacters(value) {
return value.replace(/\s+/g, " ").replace(/[!?@#$%^&*()+-,.;:'"`\\|]/g, "").trim();
}
```
 
1 message moved from Test My Bot
 

« first day (2780 days earlier)      last day (1337 days later) »