mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(post-form): convert twimg query-format links in the reply modal (#1168)
Share getPublishLinkOptions between the inline post form and the reply modal so the modal publishes twimg ?format= links in their .jpg/.png form (previously raw), and rewrite the link field on blur in both so the conversion is visible. Also gate the dev service worker's runtime asset cache to production so dev no longer serves stale /src modules.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Comment } from '@bitsocial/bitsocial-react-hooks';
|
||||
import { getExpiringMediaLinkHostname, getPublishURLFilename } from './url-utils';
|
||||
import { getLinkMediaInfo } from './media-utils';
|
||||
import { getLinkMediaInfo, getTwimgMediaFilePublishUrl } from './media-utils';
|
||||
|
||||
type TranslateFn = (key: string, options?: Record<string, unknown>) => string;
|
||||
|
||||
@@ -23,3 +24,16 @@ export const getPublishFileDisplayName = (url: string, uploadedFileName: string
|
||||
}
|
||||
return getPublishURLFilename(url) || uploadedFileName || null;
|
||||
};
|
||||
|
||||
// Build the published comment's `link`, normalizing pbs.twimg.com `?format=` media URLs to their
|
||||
// direct `.jpg`/`.png` form. `includeCurrentLink` carries through a link that another conversion
|
||||
// (e.g. the YouTube thumbnail conversion) has already written into the field. Shared by the inline
|
||||
// post form and the reply modal so the two publish paths cannot drift apart.
|
||||
export const getPublishLinkOptions = (link: string, includeCurrentLink: boolean): Partial<Pick<Comment, 'link'>> => {
|
||||
const twimgPublishUrl = getTwimgMediaFilePublishUrl(link);
|
||||
if (twimgPublishUrl) {
|
||||
return { link: twimgPublishUrl };
|
||||
}
|
||||
|
||||
return includeCurrentLink && link ? { link } : {};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user