Last active
May 10, 2021 01:04
-
-
Save tianhaoz95/b978ef584df0d66515f05f00595c16be to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const useQuery = (): URLSearchParams => { | |
| return new URLSearchParams(useLocation().search); | |
| }; | |
| const Home = (): JSX.Element => { | |
| const query = useQuery(); | |
| const wowUrl = query.get("wow"); | |
| const githubUser: string = query.get("gh_user") ? query.get("gh_user") : "wowlink"; | |
| const githubRepository: string = query.get("gh_repo") ? query.get("gh_repo") : "default-profile"; | |
| const [progress, setProgress] = useState({ msg: "init" }); | |
| useEffect(() => { | |
| const convertAndRedirect = async () => { | |
| const fetcher: LookupFetcher = GitHubLookupFetcher({ githubUser, githubRepository }); | |
| const fetcherResponse: LookupFetchResponse = await fetcher.fetch({}); | |
| const translator: UrlTranslator = BasicUrlTranslator({ fetcherResponse }); | |
| window.location.href = translator.convert({ wowUrl }).fullUrl; | |
| }; | |
| convertAndRedirect(); | |
| }, [wowUrl, githubUser, githubRepository]); | |
| return (<div className="App"><p>WOW Link: a goto link service</p></div>); | |
| }; | |
| export default (): JSX.Element => { return (<Router><Home/></Router>); }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment