Skip to content

[ShowImages] Bare imgur.com/gallery/<id> links (no slug) don't expand inline — hash read from wrong regex group #5611

Description

@af1

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/qbndDc6qbndDc6
  • gallery/foo-bar-ABCDEABCDE

Environment

  • RES master (5.24.10)
  • Chrome

Steps to reproduce

  1. Post https://imgur.com/gallery/qbndDc6
  2. Click the inline expand button — nothing expands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions