Skip to content

Have a BUG in scroll.js #1127

Closed
Closed

Description

@vagra

Bug Report

Steps to reproduce

have a BUG in scroll.js

this BUG cause:

if path and id include chinese character, it can't find some result from the nav[].

What is current behaviour

export function scrollIntoView(path, id) {
  if (!id) {
    return;
  }
  const topMargin = config().topMargin;
  const section = dom.find('#' + id);
  section && scrollTo(section, topMargin);

  const li = nav[getNavKey(path, id)];

What is the expected behaviour

last line shoule changed to:

  const li = nav[getNavKey(decodeURIComponent(path), decodeURIComponent(id))];

Other relevant information

  • Bug does still occur when all/other plugins are disabled?

  • Your OS:

  • Node.js version:

  • npm/yarn version:

  • Browser version:

  • Docsify version:

  • Docsify plugins:

Please create a reproducible sandbox

Edit 307qqv236

Mention the docsify version in which this bug was not present (if any)

Activity

  1. vagra commented on Apr 22, 2020

    @vagra
    ContributorAuthor

    when the .md file name include chinese character:

    console.log(path);
    console.log(id);
    

    result:

    /docs/%E6%A5%9E%E4%B8%A5%E7%BB%8F%EF%BC%88%E4%BE%9D%E5%9C%86%E7%91%9B%E6%B3%95%E5%B8%88%E8%AE%B2%E4%B9%89%EF%BC%89
    乙一、序分
    
    console.log(decodeURIComponent(path));
    console.log(decodeURIComponent(id));
    

    result:

    /docs/楞严经(依圆瑛法师讲义)	
    乙一、序分
    
  2. vagra commented on Apr 22, 2020

    @vagra
    ContributorAuthor

    this problem cause:
    if .md file include chinese characters, when click at the heading in main content, the sidebar links can't highlight and sync scroll.

    because const li = nav[getNavKey(path, id)] have not result.

  3. anikethsaha commented on Apr 22, 2020

    @anikethsaha
    Member

    we need to check whether this change will cause side effects or not.
    feel free to investigate and submit a fix.
    Just a note that we don't have a strong test so we should check manually whether other things are breaking cause of this or not.

  4. added a commit that references this issue on Apr 24, 2020
  5. added a commit that references this issue on May 3, 2020
  6. anikethsaha commented on May 16, 2020

    @anikethsaha
    Member

    fixed at #1146

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions