-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
1 parent
f3a8062
commit d7f0c9f
Showing
4 changed files
with
47 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
// https://regex101.com/r/RNsEkt/4 | ||
export const poeTradeUrl = /^(?:https?:\/\/)?(?:www\.)?(?:\\w+\.)?(?:pathofexile\.com|poe\.game\.daum\.net)\/trade\/search\/((?:[a-zA-Z]|%[A-Z0-9]{2})+?)\/([a-zA-Z0-9]+?)(?:\/|\/live|\/live\/)?$/; | ||
export const poeTradeUrl = /\/([a-zA-Z0-9]+)\/search\/(?:poe2\/)?([a-zA-Z0-9%]+)\/([a-zA-Z0-9]+)/; |
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,39 @@ | ||
import { poeTradeUrl } from "./RegExes"; | ||
|
||
describe("poeTradeUrl", () => { | ||
const expectedMatch =["trade", "Standard", "NK6Ec5"]; | ||
|
||
const urls = [ | ||
"https://www.pathofexile.com/trade/search/Standard/NK6Ec5/live/", | ||
"https://www.pathofexile.com/trade/search/Standard/NK6Ec5/live", | ||
"https://www.pathofexile.com/trade/search/Standard/NK6Ec5/", | ||
"https://www.pathofexile.com/trade/search/Standard/NK6Ec5", | ||
]; | ||
|
||
it("returns the correct league and id match", () => { | ||
urls.forEach(url => { | ||
const [, game, league, id] = url.match(poeTradeUrl); | ||
expect([game, league, id]).toEqual(expectedMatch); | ||
}); | ||
}); | ||
|
||
describe("when league has a space", () => { | ||
const url = "https://www.pathofexile.com/trade/search/Hardcore%20Blight/NK6Ec5"; | ||
const expectedMatch = ["trade", "Hardcore%20Blight", "NK6Ec5"]; | ||
|
||
it("returns the correct league and id match", () => { | ||
const [, game, league, id] = url.match(poeTradeUrl); | ||
expect([game, league, id]).toEqual(expectedMatch); | ||
}); | ||
}); | ||
|
||
describe("poe2", () => { | ||
const url = "https://www.pathofexile.com/trade2/search/poe2/Standard/NK6Ec5"; | ||
const expectedMatch = ["trade2", "Standard", "NK6Ec5"]; | ||
|
||
it("returns the correct league and id match", () => { | ||
const [, game, league, id] = url.match(poeTradeUrl); | ||
expect([game, league, id]).toEqual(expectedMatch); | ||
}); | ||
}); | ||
}); |