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:
Tommaso Casaburi
2026-06-09 19:24:28 +07:00
committed by GitHub
parent ee5aa7845e
commit 2f938d59ae
6 changed files with 147 additions and 28 deletions
+15 -1
View File
@@ -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 } : {};
};