mirror of
https://github.com/reiyua/github-profile-trophy-reiyua-mirror.git
synced 2026-11-17 06:02:09 +11:00
Add parseParams to utils
This commit is contained in:
parent
869c528101
commit
6a64dbe1f1
2 changed files with 11 additions and 1 deletions
3
index.ts
3
index.ts
|
|
@ -1,13 +1,14 @@
|
|||
import { ServerRequest } from "./deps.ts";
|
||||
import { GithubAPIClient } from "./src/github_api_client.ts";
|
||||
import { Card } from "./src/card.ts";
|
||||
import { parseParams } from "./src/utils.ts";
|
||||
import "https://deno.land/x/dotenv@v0.5.0/load.ts";
|
||||
|
||||
const client = new GithubAPIClient();
|
||||
const cacheMaxAge = 7200;
|
||||
|
||||
export default async (req: ServerRequest) => {
|
||||
const username = new URLSearchParams(req.url.split("?")[1]).get("username");
|
||||
const username = parseParams(req).get("username");
|
||||
|
||||
if (username != null) {
|
||||
const userInfo = await client.requestUserInfo(username);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
import { ServerRequest } from ".././deps.ts";
|
||||
|
||||
export function parseParams(req: ServerRequest): URLSearchParams {
|
||||
const splitedURL = req.url.split("?")
|
||||
if (splitedURL.length < 2){
|
||||
return new URLSearchParams();
|
||||
}
|
||||
return new URLSearchParams(splitedURL[1]);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue