Compare commits
No commits in common. "fda3e02823c9c1bb549d5b8a14cade909629caa4" and "720640b0543180920c7d7a8eb858aef7053fc2f4" have entirely different histories.
fda3e02823
...
720640b054
25
app.js
25
app.js
@ -26,10 +26,15 @@ router.get("/search", async ctx => {
|
||||
|
||||
var options = {
|
||||
thumbnails: stringToBoolean(ctx.query.thumbnails),
|
||||
icons: stringToBoolean(ctx.query.icons)
|
||||
icons: stringToBoolean(ctx.query.icons),
|
||||
ascii: stringToBoolean(ctx.query.ascii)
|
||||
};
|
||||
|
||||
ctx.body = await cachedVRCYoutubeSearch(ctx.query.pool, query, options);
|
||||
|
||||
if (options.ascii) {
|
||||
ctx.body = JSON.stringify(ctx.body).replace(/[\u007F-\uFFFF]/g, chr => "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).slice(-4));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -75,23 +80,5 @@ router.get("/", ctx => {
|
||||
|
||||
|
||||
|
||||
// work around vrchat json parser bug https://feedback.vrchat.com/udon/p/braces-inside-strings-in-vrcjson-can-fail-to-deserialize
|
||||
app.use(async (ctx, next) => {
|
||||
await next();
|
||||
if (ctx.type != "application/json") return;
|
||||
ctx.body = structuredClone(ctx.body);
|
||||
(function iterateObject(obj) {
|
||||
for (var key in obj) {
|
||||
if (typeof obj[key] == "string") {
|
||||
obj[key] = obj[key].replace(/[\[\]{}]/g, chr => "\\u" + chr.charCodeAt(0).toString(16).padStart(4, '0'));
|
||||
} else if (typeof obj[key] == "object") {
|
||||
iterateObject(obj[key]);
|
||||
}
|
||||
}
|
||||
})(ctx.body);
|
||||
ctx.body = JSON.stringify(ctx.body).replaceAll("\\\\u", "\\u");
|
||||
ctx.type = "json";
|
||||
});
|
||||
|
||||
app.use(router.routes());
|
||||
app.use(router.allowedMethods());
|
||||
|
Loading…
Reference in New Issue
Block a user