Skip to content

Commit

Permalink
Merge pull request #17 from ninoseki/improve-refang
Browse files Browse the repository at this point in the history
refactor: make more sensible to refang URI scheme
  • Loading branch information
ninoseki committed Oct 11, 2019
2 parents fa0b055 + 57d4e80 commit 007348d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.ts
Expand Up @@ -14,7 +14,8 @@ export function refang(text: string): string {
.replace(/:\]/gi, ":")
.replace(/\\\./gi, ".")
.replace(/\[\/\]/gi, "/")
.replace(/hxxp/gi, "http")
.replace(/hxxps:\/\//gi, "https://")
.replace(/hxxp:\/\//gi, "http://")
.replace(/\[(at|@)\]/gi, "@")
.replace(/\((at|@)\)/gi, "@")
.replace(/(\[|\()dot(\]|\))/gi, ".");
Expand Down
2 changes: 2 additions & 0 deletions src/spec/refanc.spec.ts
Expand Up @@ -8,4 +8,6 @@ test("refang", () => {
expect(refang("https://example[.]com")).toBe("https://example.com");

expect(refang("example.com")).toBe("example.com");

expect(refang("hxxp")).toBe("hxxp");
});

0 comments on commit 007348d

Please sign in to comment.