Skip to content

Commit f0057a0

Browse files
shatyukaJasonKhew96
authored andcommitted
fix: new pattern of private images
1 parent 12b22b1 commit f0057a0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

github-source.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,15 @@ const fetchFromGitHub = async (graphQLQuery) => {
6565
}
6666

6767
const REGEX_PUBLIC_IMAGES = /https:\/\/github\.com\/[a-zA-Z0-9-]+\/[\w\-.]+\/assets\/\d+\/([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})/g
68+
const REGEX_PUBLIC_IMAGES2 = /https:\/\/github\.com\/user-attachments\/assets\/([0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})/g
6869
const replacePrivateImage = (markdown, html) => {
6970
const publicMatches = new Map()
7071
for (const match of markdown.matchAll(REGEX_PUBLIC_IMAGES)) {
7172
publicMatches.set(match[0], match[1])
7273
}
74+
for (const match of markdown.matchAll(REGEX_PUBLIC_IMAGES2)) {
75+
publicMatches.set(match[0], match[1])
76+
}
7377
for (const match of publicMatches) {
7478
const regexPrivateImages = new RegExp(`https:\\/\\/private-user-images\\.githubusercontent\\.com\\/\\d+\\/\\d+-${match[1]}\\..*?(?=")`, 'g')
7579
html = html.replaceAll(regexPrivateImages, match[0])

0 commit comments

Comments
 (0)