diff --git a/src/lib/util.ts b/src/lib/util.ts index c305465..90fdc5a 100644 --- a/src/lib/util.ts +++ b/src/lib/util.ts @@ -72,3 +72,7 @@ export const parseResponse = (responseBody: string, splitter = ':') => { } return res } + +export const base64Decode = (input: string) => { + return Buffer.from(input, 'base64').toString('utf8') +} diff --git a/src/routes/comments/account/get.ts b/src/routes/comments/account/get.ts index f7bed57..f9be6f7 100644 --- a/src/routes/comments/account/get.ts +++ b/src/routes/comments/account/get.ts @@ -1,5 +1,10 @@ import axios from 'axios' -import { jsonResponse, parseResponse, splitGd } from '../../../lib/util' +import { + base64Decode, + jsonResponse, + parseResponse, + splitGd +} from '../../../lib/util' import { Context } from 'elysia' export const handler = async (handler: Context) => { @@ -43,7 +48,7 @@ export const handler = async (handler: Context) => { date: commentInfo['9'] + ' ago' } try { - data.content = atob(data.content) + data.content = base64Decode(data.content) } catch { data.decodeFailed = true } diff --git a/src/routes/comments/account/history/get.ts b/src/routes/comments/account/history/get.ts index 75b0e22..cdbc479 100644 --- a/src/routes/comments/account/history/get.ts +++ b/src/routes/comments/account/history/get.ts @@ -1,5 +1,5 @@ import axios from 'axios' -import { jsonResponse, parseResponse } from '../../../../lib/util' +import { base64Decode, jsonResponse, parseResponse } from '../../../../lib/util' import { Context } from 'elysia' export const handler = async (handler: Context) => { @@ -66,7 +66,7 @@ export const handler = async (handler: Context) => { } } try { - data.content = atob(data.content) + data.content = base64Decode(data.content) } catch { data.decodeFailed = true } diff --git a/src/routes/comments/level/get.ts b/src/routes/comments/level/get.ts index d219f8c..dde0cbe 100644 --- a/src/routes/comments/level/get.ts +++ b/src/routes/comments/level/get.ts @@ -1,5 +1,10 @@ import axios from 'axios' -import { jsonResponse, parseResponse, splitGd } from '../../../lib/util' +import { + base64Decode, + jsonResponse, + parseResponse, + splitGd +} from '../../../lib/util' import { Context } from 'elysia' export const handler = async (handler: Context) => { @@ -66,7 +71,7 @@ export const handler = async (handler: Context) => { } } try { - data.content = atob(data.content) + data.content = base64Decode(data.content) } catch { data.decodeFailed = true }