mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(upload-automation): harden android and electron failure handling
Updated Android/Electron upload paths to fail deterministically and report consistent stage details, while removing unsafe stage casting and path/package mismatches. This keeps postimages automation behavior intact and makes failures easier to diagnose.
This commit is contained in:
@@ -20,9 +20,11 @@ describe('direct-url', () => {
|
||||
expect(isDirectMediaUrl('https://example.com/video.gifv')).toBe(true);
|
||||
});
|
||||
|
||||
it('strips query strings before checking', () => {
|
||||
it('strips query strings and fragments before checking', () => {
|
||||
expect(isDirectMediaUrl('https://example.com/photo.jpg?size=large')).toBe(true);
|
||||
expect(isDirectMediaUrl('https://example.com/page.html?img=photo.jpg')).toBe(false);
|
||||
expect(isDirectMediaUrl('https://example.com/photo.png#section')).toBe(true);
|
||||
expect(isDirectMediaUrl('https://example.com/photo.gif#')).toBe(true);
|
||||
});
|
||||
|
||||
it('is case insensitive', () => {
|
||||
|
||||
@@ -4,7 +4,7 @@ const DIRECT_MEDIA_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.web
|
||||
/** Returns true if the URL appears to point to a direct media file (image or video) */
|
||||
export function isDirectMediaUrl(url: string): boolean {
|
||||
try {
|
||||
const normalized = url.split('?')[0].toLowerCase();
|
||||
const normalized = url.split('?')[0].split('#')[0].toLowerCase();
|
||||
return DIRECT_MEDIA_EXTENSIONS.some((ext) => normalized.endsWith(ext));
|
||||
} catch {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user