-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leave url field blank when creating cards from search page #1685
Conversation
Does this work on edge? They have a different prefix registered but can't test this myself. |
I'd recommend using a similar approach to this instead
|
Another option is to do something similar to the second half (after the &&) of this: Line 199 in 3622197
Which checks if the URL matches the protocol of import.meta.url (which will be @Kuuuube Do you have a preference? |
That looks like a cleaner solution |
Didn't know that existed. Your idea sounds better. |
Should I add a test case for this? I'm not sure if it's possible since the expected results are in plain JSON while the window location URL is platform-dependent. |
Taking a proper look at this, I feel like this is the wrong change to make. Why modify the url after it has been sent to handlebars? Especially considering the replace (or slice) that needs to be done here (could also make an element and pull out the attribute but that seems bad too). And what if there's another handlebar in the future that needs to use the url? Checking for You could throw this in before // Make URL field blank if URL source is Yomitan
if (URL.canParse(context.url) && new URL(import.meta.url).protocol === new URL(context.url).protocol) {
context.url = '';
} And if you really wanted to, stopping the empty anchor tag from being sent to anki is a simple handlebars change (it wouldn't display anything in anki regardless): {{~#*inline "url"~}}
{{~#if (op ">" definition.url.length 0)~}}
<a href="{{definition.url}}">{{definition.url}}</a>
{{~/if~}}
{{~/inline~}} |
Thanks for the help! I'll fix that |
Fixes #1558
Not sure how to add tests or if its necessary