Description
Bare gallery URLs like https://imgur.com/gallery/qbndDc6 don't expand inline in ShowImages.
Cause
In lib/modules/hosts/imgur.js, the gallery regex captures the hash into two different groups
depending on the URL shape:
const galleryHashRe = /^https?:\/\/(?:m\.|www\.)?imgur\.com\/gallery\/(?:(\w+)|(?:.*-)(\w+$))(?:[/#]|$)/i;
- Plain gallery:
/gallery/qbndDc6 → hash captured in group 1 ((\w+))
- Slug gallery:
/gallery/foo-bar-ABCDE → hash captured in group 2 ((?:.*-)(\w+$))
But the handler always reads group 2:
if ((groups = galleryHashRe.exec(href))) {
const hash = groups[2]; // undefined for plain gallery URLs
return () => _api(string.encode`gallery/${hash}`)
.catch(() => _api(string.encode`album/${hash}`));
}
So https://imgur.com/gallery/qbndDc6 resolves to gallery/undefined and album/undefined,
both fail, and nothing expands. (This is unrelated to the slug-form albums; the group 1 value is
simply being ignored for the common no-slug case.)
Proposed fix
Prefer the plain-hash group, falling back to the slug-hash group:
const hash = groups[1] || groups[2];
Verified to resolve both:
gallery/qbndDc6 → qbndDc6
gallery/foo-bar-ABCDE → ABCDE
Environment
- RES master (5.24.10)
- Chrome
Steps to reproduce
- Post
https://imgur.com/gallery/qbndDc6
- Click the inline expand button — nothing expands.
Description
Bare gallery URLs like
https://imgur.com/gallery/qbndDc6don't expand inline in ShowImages.Cause
In
lib/modules/hosts/imgur.js, the gallery regex captures the hash into two different groupsdepending on the URL shape:
/gallery/qbndDc6→ hash captured in group 1 ((\w+))/gallery/foo-bar-ABCDE→ hash captured in group 2 ((?:.*-)(\w+$))But the handler always reads group 2:
So
https://imgur.com/gallery/qbndDc6resolves togallery/undefinedandalbum/undefined,both fail, and nothing expands. (This is unrelated to the slug-form albums; the group 1 value is
simply being ignored for the common no-slug case.)
Proposed fix
Prefer the plain-hash group, falling back to the slug-hash group:
Verified to resolve both:
gallery/qbndDc6→qbndDc6gallery/foo-bar-ABCDE→ABCDEEnvironment
Steps to reproduce
https://imgur.com/gallery/qbndDc6