Skip to content

Commit

Permalink
fix(weekly): fix the image url regex (#1286)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangmy21 authored Oct 22, 2023
1 parent a9e0f8f commit 0491fe3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/routes/weekly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ router.get("/cover", async (req, res) => {
);
if (response.ok) {
const text: string = await response.text();
const match = text.match(/var msg_cdn_url.*1:1/);
if (match == null) throw(Error("capture failed!"));
const url1 = match[0].match(/https?:\/\/.*=png/);
const url2 = match[0].match(/https?:\/\/.*=jpeg/);
return res.status(200).send(url1 == null ? url2 : url1);
const match = text.match(/var msg_cdn_url = "(.*?)";/);
if (match && match[1])
res.status(200).send(match[1]);
else throw(Error("capture failed!"));
}
else return res.status(500).send("500 Internal Server Error: fetch failed!");
} catch (err) {
Expand Down

0 comments on commit 0491fe3

Please sign in to comment.