Skip to content

Don't intercept MediaWiki pages whose URL ends with .djvu (except upload.wikimedia.org) - #105

Open
frankslin wants to merge 1 commit into
RussCoder:masterfrom
frankslin:fix/103-wiki-page-urls
Open

Don't intercept MediaWiki pages whose URL ends with .djvu (except upload.wikimedia.org)#105
frankslin wants to merge 1 commit into
RussCoder:masterfrom
frankslin:fix/103-wiki-page-urls

Conversation

@frankslin

Copy link
Copy Markdown

The extension detects DjVu files by URL only, so HTML pages about a file, like https://commons.wikimedia.org/wiki/File:Foo.djvu or https://en.wikisource.org/wiki/Index:Foo.djvu, were captured as well and the viewer failed to parse them. The files themselves live on upload.wikimedia.org under /wikipedia/..., so they are still intercepted as before.

  • skip URLs on Wikimedia domains whose path starts with /wiki/ or /w/index.php (a higher priority "allow" rule for manifest v3, an early return for v2)
  • anchor the http redirect regex at the end, otherwise a partial match captured URLs like .../wiki/Page:Foo.djvu/12 and dropped the trailing part
  • honour a "djvu-js=off" query parameter as a manual opt-out, and offer a link with it in the viewer when a document fails to load, so that a wrongly intercepted page can be opened as a usual one

Fixes #103

The extension detects DjVu files by URL only, so HTML pages *about* a file,
like https://commons.wikimedia.org/wiki/File:Foo.djvu or
https://en.wikisource.org/wiki/Index:Foo.djvu, were captured as well and the
viewer failed to parse them. The files themselves live on upload.wikimedia.org
under /wikipedia/..., so they are still intercepted as before.

- skip URLs on Wikimedia domains whose path starts with /wiki/ or /w/index.php
  (a higher priority "allow" rule for manifest v3, an early return for v2)
- anchor the http redirect regex at the end, otherwise a partial match captured
  URLs like .../wiki/Page:Foo.djvu/12 and dropped the trailing part
- honour a "djvu-js=off" query parameter as a manual opt-out, and offer a link
  with it in the viewer when a document fails to load, so that a wrongly
  intercepted page can be opened as a usual one

Fixes RussCoder#103
@RussCoder

Copy link
Copy Markdown
Owner

Thank you for the PR. I will try to review it within a week.

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.

Incompatibility with Wikipedia, Wikisource & Wikimedia Commons page names

2 participants