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
Support file URLs and non-http URIs #3
Comments
|
It doesn't work for me even if it's a https URL. |
|
@DandyLyons This must be different problem, as https URLs like the one for this issue definitly work for me. Make sure the plugin is enabled and you're in edit mode when pasting. |
|
+1 Would love to use this with denonthink links. (x-devonthink-item://C6FEBBD8-109A-4309-B227) |
|
+1 Would love to use this with marginnote links. (eg: marginnote3app://note/FC25E951-1CFF-431E-899B-2724A7E8432A) |
|
Just as a walkaround, I modified the regex string in UrlIntoSelection.prototype.isUrl = function (text) {
var urlRegex = new RegExp(
"^[a-z0-9-]+:\\/\\/[a-zA-Z0-9-]+"
);
return urlRegex.test(text);
};Now I can paste marginnote links and devonthink links |
|
Hey @Benature This fix doesn't seem to work for file:/// URI's. (I imagine because of the 3 required slashes?) Thanks ♡ |
|
@NeighNeighNeigh Yes, the urlRegex above does not allow for three slashes. An URL like |
|
Oh okay cool thanks for the info, I should be able to get it working by modifying my methods for obtaining a URL for a file. Thanks again :)
… On 16 Feb 2021, at 7:43 pm, Christoph Zwerschke ***@***.***> wrote:
@NeighNeighNeigh Yes, the urlRegex above does not allow for three slashes. An URL like file:/path URLs which is also valid does not pass either - see file URI scheme for what is allowed here.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
|
@NeighNeighNeigh hello, maybe you can try UrlIntoSelection.prototype.isUrl = function (text) {
var urlRegex = new RegExp(
"^[a-z0-9-]+:(\\/){2,3}[a-zA-Z0-9-]+"
);
return urlRegex.test(text);
};it allows two or three slashes. |
|
@Benature thank you for taking the time to refine this further, I really appreciate it. Now working great over here |
|
Hi @denolehov. I was having great success using @Benature's modification- But now with the new update, if I use Benature's regex it fails. It would be nice to have the option to just forego the regex check completely– as I know I have a url in my clipboard and when I use my custom shortcut it should paste whatever is in my clipboard as URL. |
|
@NeighNeighNeigh Please try this regex: |
|
Yep working here now, thank you :) |
Closes close denolehov#3
As far as I see, this plugin checks if the clipboard contains a valid http/https URL and does not paste otherwise.
It would be nice if the plugin would also check if this is a valid file path (either POSIX or Windows) and then paste it as a link with the file URI scheme. This way you can create links to other documents or directories on your local filesystem.
It should also url encode blanks to %20 (maybe also other special characters), and in case of a Windows path, it should also convert backslashes to forward slashes.
There should be an option to use the angle bracket notation of CommonMark for links that contain spaces, instead of url encoding them. This makes the link better readable.
Also, if the clipboard content is neither a valid URL nor file path, maybe it should show an error message explaining what is wrong instead of simply doing nothing.
Maybe, if the clipboard content is a valid URI with a different scheme than http: or https: (like ftp: or mailto:) it should also be pasted. Registered and unregistered schemes (e.g. for opening certain apps) should be recognized.
The text was updated successfully, but these errors were encountered: