-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhangbin
committed
Nov 8, 2018
1 parent
c218d36
commit 2d7480a
Showing
9 changed files
with
30 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function removeProtocol(url) { | ||
return url.replace(/(^\w+:|^)\/\//, ''); | ||
} | ||
|
||
module.exports = removeProtocol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
const fs = require("fs"); | ||
const removeProtocal = require('./removeProtocal') | ||
const removeProtocol = require('./removeProtocol') | ||
|
||
function startsWith(url, pattern) { | ||
return removeProtocal(url).startsWith(removeProtocal(pattern)); | ||
return removeProtocol(url).startsWith(removeProtocol(pattern)); | ||
} | ||
|
||
module.exports = startsWith |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
"use strict"; | ||
|
||
const removeProtocal = require("../lib/removeProtocal"); | ||
const removeProtocol = require("../lib/removeProtocol"); | ||
|
||
describe("removeProtocal", () => { | ||
describe("removeProtocol", () => { | ||
it("remove http url", () => { | ||
expect(removeProtocal('http://www.abc.com/')).toMatch("www.abc.com"); | ||
expect(removeProtocol('http://www.abc.com/')).toMatch("www.abc.com"); | ||
}); | ||
it("remove https url", () => { | ||
expect(removeProtocal('https://www.abc.com/def')).toMatch("www.abc.com/def"); | ||
expect(removeProtocol('https://www.abc.com/def')).toMatch("www.abc.com/def"); | ||
}); | ||
it("remove removed url", () => { | ||
expect(removeProtocal('//www.abc.com/def?query=string')).toMatch("www.abc.com/def?query=string"); | ||
expect(removeProtocol('//www.abc.com/def?query=string')).toMatch("www.abc.com/def?query=string"); | ||
}); | ||
it("invalid url", () => { | ||
expect(removeProtocal('abc')).toMatch(""); | ||
expect(removeProtocol('abc')).toMatch(""); | ||
}); | ||
}); |