bramses / obsidian-stack-overflow

Fetch Stack Oveflow answers and copy paste them directly into Obsidian
MIT License
33 stars 0 forks source link

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

Open willasm opened 1 year ago

willasm commented 1 year ago

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.

bramses commented 1 year ago

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

Screenshot 2022-12-20 11-33-57
willasm commented 1 year ago

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.