Skip to content

Commit

Permalink
use indexOf instead of startsWith
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcorvi committed Feb 26, 2017
1 parent 94f5a24 commit 18c4f54
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/tests/hasprotocol.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default function (str:string):false|"http://"|"https://"|"ftp://"|"ftps://"|"file:///"|"mailto:" {
str = str.toLowerCase();
if(str.startsWith("http://")) return "http://";
else if(str.startsWith("https://")) return "https://";
else if(str.startsWith("ftp://")) return "ftp://";
else if(str.startsWith("ftps://")) return "ftps://";
else if(str.startsWith("file:///")) return "file:///";
else if(str.startsWith("mailto:")) return "mailto:";
if(str.indexOf("http://") === 0) return "http://";
else if(str.indexOf("https://") === 0) return "https://";
else if(str.indexOf("ftp://") === 0) return "ftp://";
else if(str.indexOf("ftps://") === 0) return "ftps://";
else if(str.indexOf("file:///") === 0) return "file:///";
else if(str.indexOf("mailto:") === 0) return "mailto:";
else return false;
}

0 comments on commit 18c4f54

Please sign in to comment.