Skip to content

Commit 3d70afc

Browse files
committed
♻️ Use encodeTitleURI
1 parent 38b5941 commit 3d70afc

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

rest/pages.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@ import type {
44
NotMemberError,
55
Page,
66
} from "../deps/scrapbox.ts";
7-
import {
8-
cookie,
9-
encodeTitle,
10-
makeCustomError,
11-
tryToErrorLike,
12-
} from "./utils.ts";
7+
import { cookie, makeCustomError, tryToErrorLike } from "./utils.ts";
8+
import { encodeTitleURI } from "../title.ts";
139
import type { Result } from "./utils.ts";
1410

1511
/** Options for `getPage()` */
@@ -34,7 +30,7 @@ export async function getPage(
3430
>
3531
> {
3632
const path = `https://scrapbox.io/api/pages/${project}/${
37-
encodeTitle(title)
33+
encodeTitleURI(title)
3834
}?followRename=${options?.followRename ?? true}`;
3935

4036
const res = await fetch(

rest/utils.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,3 @@ export function makeCustomError(name: string, message: string) {
5656
error.message = message;
5757
return error;
5858
}
59-
60-
export const toTitleLc = (title: string) =>
61-
title.toLowerCase().replaceAll(" ", "_");
62-
export const encodeTitle = (title: string) =>
63-
title.replaceAll(" ", "_").replace(
64-
/[/?#\{}^|<>]/g,
65-
(char) => encodeURIComponent(char),
66-
);

0 commit comments

Comments
 (0)