Skip to content

Commit

Permalink
fix(weekly): fix the image url regex
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangmy21 committed Oct 22, 2023
1 parent 345fa18 commit 6b375ca
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 6b375ca

Please sign in to comment.