Skip to content

Commit

Permalink
fix(pixiv): fix replacer regression (#41)
Browse files Browse the repository at this point in the history
I broke pixiv matching/replacement at some point, not sure how lol. This should fix LinkFix + Pixiv

fixes #23
  • Loading branch information
RalphORama authored Jan 9, 2024
1 parent b2c4321 commit d8b3a36
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/replacements/PixivReplacement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import BaseReplacement from "./BaseReplacement";

export default class PixivReplacement extends BaseReplacement {
constructor(newDomain: string) {
// https://github.com/thelaao/phixiv#path-formats
// don't strip query string -- member_illust.php?illust_id=:id
super(newDomain, /https?:\/\/(www\.)?pixiv\.net\/[^\s]+/g, /(www\.)?(pixiv\.net\/)/, false);
super(
newDomain,
/https?:\/\/(\w+\.)?pixiv\.net\/(\w+\/)?(artworks|member_illust\.php)(\/|\?illust_id=)\d+(\/?\d+)?[^\s]+/g,
/(\w+\.)?(pixiv\.net\/)/,
false,
);
}
}
7 changes: 4 additions & 3 deletions src/replacements/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export const replacements: {
return redditMediaReplacer ? redditMediaReplacer.replaceURLs(messageContent) : null;
},
// https://github.com/thelaao/phixiv#path-formats
"(\\/\\/|\\.)pixiv\\.net/(member_illust|(\\w+)?/artworks)": (messageContent) => {
return pixivReplacer ? pixivReplacer.replaceURLs(messageContent) : null;
},
"https?:\\/\\/(\\w+\\.)?pixiv\\.net\\/(\\w+\\/)?(artworks|member_illust\\.php)(\\/|\\?illust_id=)\\d+(\\/?\\d+)?":
(messageContent) => {
return pixivReplacer ? pixivReplacer.replaceURLs(messageContent) : null;
},
};

0 comments on commit d8b3a36

Please sign in to comment.