老版本浏览器兼容

This commit is contained in:
黄心宇 2024-03-13 10:00:48 +08:00
parent 229ca61a02
commit a50de8f797
2 changed files with 10 additions and 8 deletions

View File

@ -287,13 +287,13 @@ export function turnbar(str){
let s = str;
if(s && s.length>0){
if(s.indexOf("%")>-1){
s = s.replaceAll('%','_25');
s = s.replace(/%/g,'_25');
}
if(s.indexOf("#")>-1){
s = s.replaceAll('#','%23');
s = s.replace(/#/g,'%23');
}
if(s.indexOf("/")>-1){
s = s.replaceAll('/','%2F');
s = s.replace(/\//g,'%2F');
}
}
return s;
@ -302,13 +302,13 @@ export function returnbar(str){
let s = str;
if(s && s.length>0){
if(str.indexOf("_25")>-1){
s = s.replaceAll('_25','%');
s = s.replace(/_25/g,'%');
}
if(s.indexOf("%23")>-1){
s = s.replaceAll('%23','#');
s = s.replace(/%23/g,'#');
}
if(s.indexOf("%2F")>-1){
s = s.replaceAll('%2F','/');
s = s.replace(/%2F/g,'/');
}
}
return s;

View File

@ -93,7 +93,7 @@ export default ({
for(var x=0;x<issues.length;x++){
let item = issues[x];
let content = item.id ? `<a href="`+`/${owner}/${projectsId}/issues/${item.project_issues_index}`+`">#${item.project_issues_index}:${item.subject}</a>` : `<span>#${item.project_issues_index}(已删除)</span>`;
rs = rs.replaceAll(`<a href="`+`/${owner}/${projectsId}/issues/${item.project_issues_index}`+`">#${item.project_issues_index}</a>`,content);
rs = rs.replace(new RegExp(`<a href="/${owner}/${projectsId}/issues/${item.project_issues_index}">#${item.project_issues_index}</a>`, 'g'), content);
}
}
@ -102,7 +102,9 @@ export default ({
return renderToString(_unescape(expression) || '', { displayMode: type === 'block', throwOnError: false, output: 'html' })
})
rs = dompurify.sanitize(rs.replace(/▁/g, "▁▁▁"))
rs = rs.replaceAll('<img ', `<img onerror="javascript:this.src='${ imgError }';"`)
rs = rs.replace(/<img\s+/g, function(match) {
return match + `onerror="javascript:this.src='${imgError}';" `;
});
resetMathExpressions()
return rs
}, [str,issues]);