GithubHelp home page GithubHelp logo

Comments (13)

whisperity avatar whisperity commented on July 27, 2024 1

You are getting an https:// from somewhere and sending it. That's different from what I can see. For me, the : separator after the hostname remains in the URL that appears...

What is your git config --get remote.origin.url? Because based on the logic I can see in the source code, I don't see what or where the proper http:// is getting applied.

For me, git config --get remote.origin.url is the following: github.com:username/project.git. There is no git@! There is no ssh://! Your code in the fix begins with:

if (remoteUrl.stdout.startsWith('git@') || remoteUrl.stdout.startsWith('ssh://')) {

This is FALSE and the branch is not taken in case of the remoteURL is set up in a way that is set up for me, and how it is explained in the original ticket.

from coc-discord-rpc.

whisperity avatar whisperity commented on July 27, 2024 1

I'm not knowledgeable much about TypeScript and don't have the appropriate execution environment, but I've rewritten the code in the proposed fix to Python for ease of debugging:

import re

def rewrite(url):
    if url.startswith("ssh://") or url.startswith("git@"):
        url = url.replace("ssh://", "") \
            .replace(":", "/") \
            .replace("git@", "https://") \
            .replace(".git", "") \
            .replace("\n", "")
        return url
    else:
        regexp = re.compile(r"(https:\/\/)([^@]*)@(.*?$)")
        url = re.sub(regexp, r"\1\3", url) \
            .replace(".git", "") \
            .replace("\n", "")
        return url

Now, running the following test code:

print(rewrite("http://github.com/foo/bar.git"))
print(rewrite("http://github.com/foo/bar"))
print(rewrite("[email protected]:foo/bar.git"))
print(rewrite("[email protected]:foo/bar"))
print(rewrite("github.com:foo/bar.git"))
print(rewrite("github.com:foo/bar"))

When running, I get

http://github.com/foo/bar
http://github.com/foo/bar
https://github.com/foo/bar
https://github.com/foo/bar
github.com:foo/bar
github.com:foo/bar

instead of the last two lines being http://github.com/foo/bar.

from coc-discord-rpc.

whisperity avatar whisperity commented on July 27, 2024 1

I've found this library, written in pure JavaScript: https://github.com/IonicaBizau/git-url-parse. Perhaps you could use this to parse all the components of the remote URL in a portable way, and use the resulting struct to build the URL sent to Discord.

from coc-discord-rpc.

whisperity avatar whisperity commented on July 27, 2024 1

Alright, can confirm it works now properly! (As in, sans the Discord bug.)
Hang on! This link will take you to http://github.com/whisperity/llvm-project. Are you sure you want to go there?

from coc-discord-rpc.

leonardssh avatar leonardssh commented on July 27, 2024

Fixed. 983ed00

Please update the extension and let me know if the problem is solved.

from coc-discord-rpc.

whisperity avatar whisperity commented on July 27, 2024

Not fixed yet.

I've updated to [email protected]. The button now appears! However, for some reason, it does not react to clicks, as if no action was attached to it.

Inside Discord, the DOM is the following:

<button
  type="button"
  class="button-2IFFQ4
    button-38aScr
    lookFilled-1Gx00P
    colorGrey-2DXtkV
    buttonSize-AQY2mE
    grow-q77ONN"
  >
    <div class="contents-18-Yxp">
        View Repository
    </div>
</button>

In 983ed00 you are replacing git@ which is not necessarily part of the remote URL set in Git. It is not mandated that the remote SSH username must be git on the remote server — e.g. when the server uses Gitolite, it is more often than not gitolite in a standard installation. Similarly, gerrit for Gerrit.
That's why you usually use the User variable in ~/.ssh/config. You give a hostname (any hostname, but conventionally the actual hostname) which SSH connections (including Git remote URL specifiers) can use, but everything else, like the remote username, the port used (which might not be the standard 22 port!), the key to use for authentication, port forwards, etc., is configured in the config file for your account.

I think the issue is because the URL set in the RPC call isn't a website, but a bare protocol-less URI. In the debugger view, the following appears in the log:

[RPCServer:IPC] Socket Message: 13

{
  "cmd": "SET_ACTIVITY",
  "data": {
    "application_id": "768090036633206815",
    "assets": {
      "large_image": "811014712325439508",
      "large_text": "Editing a CPP file",
      "small_image": "799113198741094442",
      "small_text": "NeoVim v0.6.0"
    },
    "buttons": ["View Repository"],
    "details": "In Dummy - 0 problems found",
    "metadata": {
      "button_urls": ["github.com:username/project"],
      "__proto__": Object
    },
    "name": "NeoVim",
    "state": "Viewing dummy.cpp",
    "type": 0,
    "__proto__": Object,
    },
  "evt": null,
  "nonce": "0123457-abcd-abcd-abcd-0123456789abc",
  "__proto__": Object,
}

The URL sent to Discord at data.metadata.button_urls[0] should be http://github.com/username/project.

from coc-discord-rpc.

leonardssh avatar leonardssh commented on July 27, 2024

I've updated to [email protected]. The button now appears! However, for some reason, it does not react to clicks, as if no action was attached to it.

See leonardssh/vscord#20 (comment)

The URL sent to Discord at data.metadata.button_urls[0] should be http://github.com/username/project

What I send to discord, is the proper link, I don't know why discord doesn't set it properly.
image

This happens with other extensions on the market too.

from coc-discord-rpc.

leonardssh avatar leonardssh commented on July 27, 2024

See what I can do. Thanks mate.

from coc-discord-rpc.

leonardssh avatar leonardssh commented on July 27, 2024

I tested the library you showed me, and it really works.

Input:

JSON.stringify({
    1: gitUrlParse('http://github.com/foo/bar.git').toString('https').replace('.git', ''),
    2: gitUrlParse('http://github.com/foo/bar').toString('https'),
    3: gitUrlParse('[email protected]:foo/bar.git').toString('https').replace('.git', ''),
    4: gitUrlParse('[email protected]:foo/bar').toString('https'),
    5: gitUrlParse('github.com:foo/bar.git').toString('https').replace('.git', ''),
    6: gitUrlParse('github.com:foo/bar').toString('https')
}, null, 4);

Output:

{
    "1": "https://github.com/foo/bar",
    "2": "https://github.com/foo/bar",
    "3": "https://github.com/foo/bar",
    "4": "https://github.com/foo/bar",
    "5": "https://github.com/foo/bar",
    "6": "https://github.com/foo/bar"
}

I think I'll replace it with what I hardcoded.

from coc-discord-rpc.

leonardssh avatar leonardssh commented on July 27, 2024

But the button still cannot be clicked by yourself. I logged in from another discord account, and I can click the button on my profile.

¯\_(ツ)_/¯

from coc-discord-rpc.

leonardssh avatar leonardssh commented on July 27, 2024
button.mp4

from coc-discord-rpc.

whisperity avatar whisperity commented on July 27, 2024

Alright, that I understand (it's weird and very well could be a Discord bug), but that does not change the fact that the fix shown is not a fix, because it does not rewrite the URLs correctly. If git@ or ssh:// isn't in the URL, it's handled in the exact same broken way as before.

Nvm, I saw the previous comments.

The Discord bug is weird, though, because e.g. with Spotify it explicitly shows an error message when you want to click on listening what you're already listening to. 🤔

from coc-discord-rpc.

leonardssh avatar leonardssh commented on July 27, 2024

🙄

from coc-discord-rpc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.