打开你的依赖node_modules\karma\node_modules\connect\lib\patch.js
将里面的setHeader方法改成下面这样,干掉序列化日期时出现的中文
res.setHeader = function(field, val){ var key = field.toLowerCase() , prev; // special-case Set-Cookie if (key === ‘set-cookie‘) { // detect code doing getHeader -> setHeader if (Array.isArray(val) && val.length > 1) { prev = [].concat(this.getHeader(field) || []); val = unique(prev, val); } return this.appendHeader(field, val); } // charset if (‘content-type‘ == key && this.charset) { val = utils.setCharset(val, this.charset, true); } try{ if(typeof val === ‘string‘){ val = val.replace(/中国标准时间/,‘‘) } return setHeader.call(this, field, val); }catch(e){ console.log(e, val,field) } };
出处:https://www.cnblogs.com/rubylouvre/p/6127190.html?utm_source=tuicool&utm_medium=referral
时间: 2024-10-25 23:52:28