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:
plebeius
2026-02-20 16:52:35 +08:00
parent 15d608764b
commit b20aae8244
12 changed files with 58 additions and 21 deletions
@@ -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', () => {
+1 -1
View File
@@ -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;