Skip to content

Bug: Duplicated ?plain=1 when using the github_browse router #289

@boiledfroginthewell

Description

@boiledfroginthewell
  1. What's the output of git remote get-url origin?

    It's https://github.com/linrongbin16/gitlinker.nvim.git

  2. what's the expect git host url you want to generate?

    It's
    https://github.com/linrongbin16/gitlinker.nvim/blob/d2a250e65207ddc04724579b99e564da01922a65/README.md?plain=1#L1
    but was
    https://github.com/linrongbin16/gitlinker.nvim/blob/d2a250e65207ddc04724579b99e564da01922a65/README.md?plain=1?plain=1#L1

  3. how do you configure this plugin?

    It's ...

{
  "linrongbin16/gitlinker.nvim",
  cmd = "GitLink",
  opts = function ()
    return {
      router = {
        browse = {
          ["my.custom.github.enterprise.host.example.com"] = require('gitlinker.routers').github_browse,
          -- The default router for github.com works correctly.
          -- The following line intentionally assigns the github_browse router
          -- to github.com in order to reproduce this bug.
          ["^github.com"] = require('gitlinker.routers').github_browse,
        }
      }
    }
  end,
},

(This issue occurs with GitHub Enterprise, but can be reproduced on github.com by intentionally assigning the github_browse router.)

  1. What's your OS and Neovim version?

    The OS is: Manjaro x86_64 (Intel chip), MacOS M1 chip

    The Neovim version (nvim --version) is: ...

NVIM v0.11.5
Build type: RelWithDebInfo
LuaJIT 2.1.1753364724

Description

When generating a link for a Markdown file with GitHub Enterprise, ?plain=1 is incorrectly appended twice to the URL. As a result, the generated URL is

  • unable to open a link in plain mode.
  • not replaced with a code preview when pasted in issue/PR comments.

Example:

It seems this issue is specific to Markdown files.

Repro

  1. Clone https://github.com/linrongbin16/gitlinker.nvim.git and open README.md.
  2. Run :GitLink with the above config.
  3. The generated URL contains the duplicated ?plain=1.

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