quarto-dev / quarto-dev/quarto-cli

Don't strip index.html from external links

Open
#11,527 8 comments 1 reaction 1 assignee View on GitHub

@cscheid is already working on this.

Since Nov 25, 2024.

bug websites
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

Bug description

This issue was previously reported at #8852 but was not actually resolved. A change was made at https://github.com/quarto-dev/quarto-cli/pull/8853

Simply, /index.html in the following link will be replaced, which is not okay.

https://api.visitorbadge.io/api/visitors?path=https://github.com/index.html

The issue is still the same: https://github.com/quarto-dev/quarto-cli/blob/e29433f77b684d231e86d844e5d43d4df7a9c655/src/resources/projects/website/navigation/quarto-nav.js#L277

const links = window.document.querySelectorAll("a");
    for (let i = 0; i < links.length; i++) {
      if (links[i].href) {
        links[i].dataset.originalHref = links[i].href;
        links[i].href = links[i].href.replace(/\/index\.html/, "/");
      }
    }

There are two issues:

  • .replace(/\/index\.html/, "/") replaces /index.html anywhere in the link, not just the end of the string
"https://github.com/index.html#diff".replace(/\/index\.html/, "/") => 'https://github.com/#diff'
"https://github.com/index.html/diff".replace(/\/index\.html/, "/") => 'https://github.com//diff'
  • const links = window.document.querySelectorAll("a"); selects all links. It should probably avoid links with certain class, or attributes, eg:
// Exclude links with data-exclude attribute
document.querySelectorAll('a:not([data-exclude])')
Steps to reproduce

No response

Expected behavior

No response

Actual behavior

No response

Your environment

No response

Quarto check output
Quarto 1.5.57
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.57
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: (external install)
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Version: 2024

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.10.12
      Jupyter: 5.7.2
      Kernels: python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.