Listing category filter and URL hash disagree after Back, or with `&`, `=` or `%` in a category

Offen Anfängerfreundlich
#15,340 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
72/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
javascript
Bereich
frontend

Rechercherichtung

Beginne mit quarto-listing.js, insbesondere mit applyListingHash, makeHash und parseHash, und reproduziere dann die drei Fälle in einem gerenderten Listing mit den bereitgestellten Kategorienamen. Prüfe, wie Zurück zur unveränderten URL den Filter zurücksetzt und wie codierte Kategorienamen Neuladevorgänge überstehen. Fertig ist die Aufgabe, wenn bei der unveränderten URL alle Einträge ohne ausgewählte Kategorie erscheinen und jede Kategorie mit Sonderzeichen ihren passenden Eintrag auswählt und anzeigt, ohne einen Konsolenfehler zu verursachen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug listings
I have
  • searched the issue tracker for similar issues
  • installed the latest version of Quarto CLI
  • formatted my issue following the Bug Reports guide
Bug description

The category filter of a listing can disagree with the #category= hash in the URL.

applyListingHash in quarto-listing.js returns early when there is no hash, and it only filters when the category is not empty, so Back to the bare URL or to #category= never shows all items again.

Category names with &, = or % break after a reload or a shared link.
makeHash writes the name without encoding, parseHash splits on & and =, and the value is decoded twice: once in parseHash and again in applyListingHash.
So R&D is read as R, and 100% throws URIError: URI malformed in window["quarto-listing-loaded"], before pagination and progressive images are wired.

With #15339, item category tags become links, so a Ctrl or middle click on a tag opens such a URL in a new tab.

Related: #11752, #10829, #15339.

Steps to reproduce

_quarto.yml:

project:
  type: website
website:
  title: "Listing"

index.qmd:

---
title: "Posts"
listing:
  contents: posts
  categories: true
---

posts/one.qmd:

---
title: "Post one"
date: 2026-01-01
categories: [alpha, "R&D"]
---

Text.

posts/two.qmd:

---
title: "Post two"
date: 2026-01-02
categories: [beta, "100%"]
---

Text.

Render the website and open _site/index.html.

  1. Click "alpha" in the categories filter, then press Back.
  2. Click "R&D", then reload the page.
  3. Click "100%", then reload the page.
Actual behavior
  1. The URL has no hash, but the listing still shows one item and "alpha" is still active.
  2. The URL is #category=R&D, the listing shows no items, and no entry is active.
  3. The URL is #category=100%, the console shows URIError: URI malformed, both items show, and no entry is active.
Expected behavior
  1. Back to the bare URL shows all items, with no category active ("All" is active in the numbered style).
  2. After a reload, the listing shows the one "R&D" item, and "R&D" is active.
  3. After a reload, the listing shows the one "100%" item, "100%" is active, and the console has no error.
Your environment
  • Quarto built from main (ac310a424). The listing script is main's quarto-listing.js.
  • Browser: Brave (Chromium) on macOS 27.2.
Quarto check output
Quarto 99.9.9
[✓] Checking environment information...
      Quarto cache location: /Users/mcanouil/Library/Caches/quarto
      Project: none found (single-file mode)
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.10.0: OK
      Dart Sass version 1.107.1: OK
      Deno version 2.9.8: OK
      Typst version 0.15.1: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 99.9.9
      Path: /Users/mcanouil/Projects/quarto-dev/quarto-cli/package/dist/bin
[✓] Checking basic markdown render....OK
Vorherrschende Sprache
JavaScript
Sterne
6.2k
Forks
482
Ø Merge
17 Std. 46 Min.
Gemergte PRs (30 T.)
135

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus quarto-dev/quarto-cli

Alle Issues in quarto-dev/quarto-cli

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.