Skip to content

Fix downloads blocked for URLs with non-standard file extensions#242

Merged
DanAtkinson merged 3 commits into
masterfrom
copilot/fix-non-standard-file-formats
Jul 9, 2026
Merged

Fix downloads blocked for URLs with non-standard file extensions#242
DanAtkinson merged 3 commits into
masterfrom
copilot/fix-non-standard-file-formats

Conversation

Copilot AI commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

URLs with non-standard file extensions (e.g. .bro) were silently excluded from downloads in Fuskr v5+, despite the images being valid and accessible. This broke patterns like http://cdn.gtresnews.com/zooms12/00000002723/u598538_[001-010].bro.

Root cause

isValidMediaUrl in gallery.component.ts used a hardcoded extension whitelist to gate download eligibility:

// Before: only these passed
const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.bmp', '.svg'];
const videoExtensions = ['.mp4', '.webm', '.avi', '.mov', '.mkv', '.flv', '.wmv', '.m4v'];

Any URL whose path didn't end with a known extension returned false, blocking it from the ZIP download. For type: 'unknown' items (which non-standard extensions get), this also blocked display.

Changes

  • gallery.component.ts: Removed extension whitelist from isValidMediaUrl. Now rejects only data:, blob:, and non-HTTP/HTTPS URLs. Type detection via Content-Type headers (HEAD requests) is unaffected and handles actual media validation.

  • Tests (gallery.component.spec.ts, fuskr.service.spec.ts, media-type.service.spec.ts): Added coverage for non-standard extension URLs — confirming they pass isValidMediaUrl, generate correct enumerated URL sequences, and resolve to the correct media type via HEAD request.

Copilot AI linked an issue Jul 9, 2026 that may be closed by this pull request
Copilot AI added 2 commits July 9, 2026 19:03
…iltering

The isValidMediaUrl method in gallery.component.ts was filtering out URLs based
on file extension, causing URLs with non-standard extensions (e.g. .bro) to be
excluded from downloads. The check was too restrictive — any valid HTTP/HTTPS URL
should be allowed through, with type detection handled by Content-Type headers
via HEAD requests.

Removed the extension whitelist from isValidMediaUrl. The function now only
rejects data: and blob: URLs, plus non-HTTP/HTTPS schemes.

Added tests for:
- createFuskUrl and generateImageGallery with non-standard extensions (fuskr.service.spec.ts)
- fallbackTypeDetection and HEAD-based detection for .bro URLs (media-type.service.spec.ts)
- isValidMediaUrl accepting non-standard extensions (gallery.component.spec.ts)
- getValidImageUrls including non-standard extension URLs (gallery.component.spec.ts)
Copilot AI changed the title [WIP] Fix Fuskr to recognize non-standard file formats Fix downloads blocked for URLs with non-standard file extensions Jul 9, 2026
Copilot AI requested a review from DanAtkinson July 9, 2026 19:07

@DanAtkinson DanAtkinson left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the changes to package.json? The file should be LF and UTF-8.

Copilot AI commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

What are the changes to package.json? The file should be LF and UTF-8.

The only change to package.json is line ending normalization — CRLF → LF. No content was added, removed, or modified. The file is already stored as LF UTF-8 in the git blob (the working-copy CRLF you may see is applied on checkout by the .gitattributes eol=crlf rule for *.json). No further changes are needed to package.json itself.

Copilot AI requested a review from DanAtkinson July 9, 2026 19:26
@DanAtkinson DanAtkinson marked this pull request as ready for review July 9, 2026 19:43
Copilot AI review requested due to automatic review settings July 9, 2026 19:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Fuskr v5+ downloads being blocked for valid media URLs that use non-standard file extensions (e.g. .bro) by relaxing URL validation and adding regression tests around URL enumeration and media-type detection.

Changes:

  • Simplified GalleryComponent.isValidMediaUrl to allow any HTTP/HTTPS URL (still rejecting data: and blob:).
  • Added tests ensuring .bro URLs are accepted by gallery URL filtering and that URL range generation works with non-standard extensions.
  • Added tests verifying media type detection can still resolve type via Content-Type (HEAD) for non-standard extensions, and falls back gracefully on failure.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/app/components/gallery.component.ts Removes extension whitelist gating; URL validity is now based on scheme/prefix checks only.
src/app/components/gallery.component.spec.ts Adds regression tests for .bro URLs in getValidImageUrls and isValidMediaUrl.
src/app/services/fuskr.service.spec.ts Adds coverage for fusk URL creation and gallery generation with non-standard extensions.
src/app/services/media-type.service.spec.ts Adds coverage for .bro fallback detection + HEAD Content-Type-based detection behavior.
package.json No functional dependency/script changes observed (appears to be a reformat/no-op change).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1535 to +1550
it('should include URLs with non-standard file extensions', () => {
const img = document.createElement('img');
img.className = 'fusk-image';
Object.defineProperty(img, 'complete', { value: true });
Object.defineProperty(img, 'naturalHeight', { value: 100 });
img.src = 'https://cdn.example.com/images/u598538_001.bro';

document.body.appendChild(img);

const urls = (
component as unknown as {
getValidImageUrls: () => string[];
}
).getValidImageUrls();
expect(urls).toContain('https://cdn.example.com/images/u598538_001.bro');
});
@DanAtkinson DanAtkinson merged commit ff12a10 into master Jul 9, 2026
9 checks passed
@DanAtkinson DanAtkinson deleted the copilot/fix-non-standard-file-formats branch July 9, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-standard file formats

3 participants