-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathqiita-cli-url.ts
44 lines (35 loc) · 966 Bytes
/
qiita-cli-url.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
type ItemsShowQueryKeys = "basename";
type ItemsShowQueryParams = Record<ItemsShowQueryKeys, string>;
export const itemsIndexPath = () => {
return "/";
};
export const itemsShowPath = (
itemId: string,
params?: ItemsShowQueryParams,
): string => {
const url: string = `/items/${itemId}`;
if (itemId === "show" && params) {
const query = new URLSearchParams(params).toString();
return `${url}?${query}`;
} else {
return url;
}
};
export const apiItemsShowPath = (
itemId: string,
params?: ItemsShowQueryParams,
): string => {
const url: string = `/api/items/${itemId}`;
if (itemId === "show" && params) {
const query = new URLSearchParams(params).toString();
return `${url}?${query}`;
} else {
return url;
}
};
export const apiItemsUpdatePath = (itemId: string): string => {
return `/api/items/${itemId === "show" ? "post" : itemId}`;
};
export const apiReadmeShowPath = () => {
return "/api/readme";
};