|
|
@ -6,9 +6,16 @@ import axios from "axios";
|
|
|
|
|
|
|
|
|
|
|
|
const router = new Router();
|
|
|
|
const router = new Router();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const href_regex = /href="\/"/g;
|
|
|
|
|
|
|
|
|
|
|
|
router.get("/", async (ctx) => {
|
|
|
|
router.get("/", async (ctx) => {
|
|
|
|
const url = ctx.query.url;
|
|
|
|
const url = ctx.query.url;
|
|
|
|
|
|
|
|
const rewrite = ctx.query.url;
|
|
|
|
const response = await axios.get(url);
|
|
|
|
const response = await axios.get(url);
|
|
|
|
|
|
|
|
if (response.data.replace && rewrite) {
|
|
|
|
|
|
|
|
const origin = new URL(url).origin;
|
|
|
|
|
|
|
|
response.data = response.data.replace(href_regex, `href="${origin}/`);
|
|
|
|
|
|
|
|
}
|
|
|
|
ctx.body = response.data;
|
|
|
|
ctx.body = response.data;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|