Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fixNoteContentForSend: function(content) {
if(!content) {
return content;
}
// console.log(Evt.localUrl + '/api/file/getImage');
// console.log(content);
var reg = new RegExp(Evt.getImageLocalUrlPrefix(), 'g');
content = content.replace(reg, Evt.leanoteUrl + '/api/file/getImage');
var reg2 = new RegExp(Evt.getAttachLocalUrlPrefix(), 'g');
content = content.replace(reg2, Evt.leanoteUrl + '/api/file/getAttach');
var reg3 = new RegExp(Evt.getAllAttachsLocalUrlPrefix(), 'g');
content = content.replace(reg3, Evt.leanoteUrl + '/api/file/getAllAttachs');
return content;
},
needle.post(this.getUrl('auth/login', {macAddr: macAddr}), {email: email, pwd: pwd}, {timeout: 10000}, function(error, response) {
me.checkError(error, response);
if(error) {
return callback && callback(false);
}
// needle.get('http://localhost/phpinfo.php?email=xx', {emai: email, pwd: pwd}, function(error, response) {
var ret = response.body;
// 登录成功, 保存token
// console.log('login ret');
// console.log(ret);
if(Common.isOk(ret)) {
ret.Pwd = Common.md5(pwd, ret.UserId);
ret['Host'] = Evt.leanoteUrl;
// User.setCurUser(ret);
callback && callback(ret);
} else {
// console.log('log failed');
callback && callback(false);
}
});
},
fixNoteContentForSend: function(content) {
if(!content) {
return content;
}
// console.log(Evt.localUrl + '/api/file/getImage');
// console.log(content);
var reg = new RegExp(Evt.getImageLocalUrlPrefix(), 'g');
content = content.replace(reg, Evt.leanoteUrl + '/api/file/getImage');
var reg2 = new RegExp(Evt.getAttachLocalUrlPrefix(), 'g');
content = content.replace(reg2, Evt.leanoteUrl + '/api/file/getAttach');
var reg3 = new RegExp(Evt.getAllAttachsLocalUrlPrefix(), 'g');
content = content.replace(reg3, Evt.leanoteUrl + '/api/file/getAllAttachs');
return content;
},
fixNoteContent: function(content) {
if(!content) {
return content;
}
// http://leanote.com/file/outputImage?fileId=54f9079f38f4115c0200001b
var reg0 = new RegExp(Evt.leanoteUrl + '/file/outputImage', 'g');
content = content.replace(reg0, Evt.localUrl + '/api/file/getImage');
var reg = new RegExp(Evt.leanoteUrl + '/api/file/getImage', 'g');
content = content.replace(reg, Evt.localUrl + '/api/file/getImage');
var reg2 = new RegExp(Evt.leanoteUrl + '/api/file/getAttach', 'g');
content = content.replace(reg2, Evt.localUrl + '/api/file/getAttach');
// api/file/getAllAttachs?noteId=xxxxxxxxx, 这里的noteId是服务器上的noteId啊
var reg3 = new RegExp(Evt.leanoteUrl + '/api/file/getAllAttachs', 'g');
content = content.replace(reg3, Evt.localUrl + '/api/file/getAllAttachs');
return content;
},
getUrl: function(url, param) {
var url = Evt.leanoteUrl + '/api/' + url;
// leanote ssl不能非法
if (url.indexOf('https://leanote.com') == 0) {
needle.defaults({
timeout: 60000,
rejectUnauthorized: true
});
} else {
needle.defaults({
timeout: 60000,
rejectUnauthorized: false
});
}
var token = User.getToken();
param = param || {};
param.token = token;
if(param) {
fixNoteContent: function(content) {
if(!content) {
return content;
}
// http://leanote.com/file/outputImage?fileId=54f9079f38f4115c0200001b
var reg0 = new RegExp(Evt.leanoteUrl + '/file/outputImage', 'g');
content = content.replace(reg0, Evt.localUrl + '/api/file/getImage');
var reg = new RegExp(Evt.leanoteUrl + '/api/file/getImage', 'g');
content = content.replace(reg, Evt.localUrl + '/api/file/getImage');
var reg2 = new RegExp(Evt.leanoteUrl + '/api/file/getAttach', 'g');
content = content.replace(reg2, Evt.localUrl + '/api/file/getAttach');
// api/file/getAllAttachs?noteId=xxxxxxxxx, 这里的noteId是服务器上的noteId啊
var reg3 = new RegExp(Evt.leanoteUrl + '/api/file/getAllAttachs', 'g');
content = content.replace(reg3, Evt.localUrl + '/api/file/getAllAttachs');
return content;
},
fixNoteContent: function(content) {
if(!content) {
return content;
}
// https, http都行
var url = Evt.leanoteUrl.replace('https', 'https*');
// http://leanote.com/file/outputImage?fileId=54f9079f38f4115c0200001b
var reg0 = new RegExp(url + '/file/outputImage', 'g');
content = content.replace(reg0, Evt.getImageLocalUrlPrefix());
var reg = new RegExp(url + '/api/file/getImage', 'g');
content = content.replace(reg, Evt.getImageLocalUrlPrefix());
var reg2 = new RegExp(url + '/api/file/getAttach', 'g');
content = content.replace(reg2, Evt.getAttachLocalUrlPrefix());
var reg3 = new RegExp(url + '/attach/download?attachId', 'g');
content = content.replace(reg3, Evt.getAttachLocalUrlPrefix() + '?fileId');
// 无用
// api/file/getAllAttachs?noteId=xxxxxxxxx, 这里的noteId是服务器上的noteId啊