mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(cloudfunc) add decodeEntities
This commit is contained in:
parent
ea949f0b81
commit
e7822af805
1 changed files with 26 additions and 7 deletions
|
|
@ -33,14 +33,33 @@ var Util;
|
|||
this.CHANNEL_TERMINAL_RESIZE= 'terminal-resize';
|
||||
this.MAX_FILE_SIZE = 500 * 1024;
|
||||
|
||||
function encodeEntities(str) {
|
||||
str = str
|
||||
.replace(/\s/g, ' ')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
var Entities = {
|
||||
' ': ' ',
|
||||
'<': '<',
|
||||
'>' : '>'
|
||||
};
|
||||
|
||||
this.encodeEntities = function(str) {
|
||||
Object.keys(Entities).forEach(function(code) {
|
||||
var char = Entities[code],
|
||||
reg = RegExp(char, 'g');
|
||||
|
||||
str = str.replace(reg, code);
|
||||
});
|
||||
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
this.decodeEntities = function(str) {
|
||||
Object.keys(Entities).forEach(function(code) {
|
||||
var char = Entities[code],
|
||||
reg = RegExp(code, 'g');
|
||||
|
||||
str = str.replace(reg, char);
|
||||
});
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
this.formatMsg = function(msg, name, status) {
|
||||
if (!status)
|
||||
|
|
@ -231,7 +250,7 @@ var Util;
|
|||
|
||||
linkResult = render(templateLink, {
|
||||
link : link,
|
||||
name : encodeEntities(file.name),
|
||||
name : CloudFunc.encodeEntities(file.name),
|
||||
attribute : attribute
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue