Skip to content

Commit

Permalink
startswith添加try catch,提高稳定性
Browse files Browse the repository at this point in the history
  • Loading branch information
1234567Yang authored Nov 9, 2024
1 parent 89285ac commit 8fcb8cd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion _worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ var mainOnly = path.substring(0, path.indexOf("://")) + "://" + original_host +
//---***========================================***---通用func---***========================================***---
function changeURL(relativePath){
if(relativePath == null) return null;
if(relativePath.startsWith("data:") || relativePath.startsWith("mailto:") || relativePath.startsWith("javascript:") || relativePath.startsWith("chrome") || relativePath.startsWith("edge")) return relativePath;
try{
if(relativePath.startsWith("data:") || relativePath.startsWith("mailto:") || relativePath.startsWith("javascript:") || relativePath.startsWith("chrome") || relativePath.startsWith("edge")) return relativePath;
}catch{
// duckduckgo mysterious BUG that will trigger sometimes, just ignore ...
}
try{
if(relativePath && relativePath.startsWith(nowlink)) relativePath = relativePath.substring(nowlink.length);
if(relativePath && relativePath.startsWith(base + "/")) relativePath = relativePath.substring(base.length + 1);
Expand Down

0 comments on commit 8fcb8cd

Please sign in to comment.