obsidian-stack-overflow icon indicating copy to clipboard operation
obsidian-stack-overflow copied to clipboard

[BUG] Not working as it currently stands. Stackoveflow ID links have changed.

Open willasm opened this issue 2 years ago • 2 comments

The example answer url you used has the ID at the as second last set of numbers..

https://stackoverflow.com/a/72722933/3952024

But now when it is copied from stackoverflow the ID is now at the end, like this...

https://stackoverflow.com/a/72722933

I was able to fix this in main.js by commenting out the first urlPopped.pop(); and now it works as expected.

willasm avatar Dec 18 '22 09:12 willasm

hmm mine still has the first hash, are you logged into S/O?

Screenshot 2022-12-20 11-33-57

bramses avatar Dec 20 '22 17:12 bramses

That is what it was. I actually did not have an account but created one to test this (I use it enough anyways). This is an easy fix as well, I just changed the code a bit to this...

    const urlPopped = url.split("/");
    const urlLast = urlPopped.pop();
    const urlSecondLast = urlPopped.pop();
    if (urlSecondLast === "a") {
        return urlLast;
    }
    return urlSecondLast;

This will work whether a user is logged in or not.

willasm avatar Dec 20 '22 20:12 willasm