Script "open url" action no longer works

I have the following script that used to work, but no longer does. The console (following the log item) displays what appears to be a valid url, but then nothing happens in drafts and the following error is left in the log: App.openURL: Invalid URL

Action: URL Cursor (copy) | Drafts Directory
Sample draft

[GitHub - lynchjames/obsidian-writing-goals: Set yourself dynamic writing goals for notes and folders to help you hit your long form writing targets with Obsidian.](https://github.com/lynchjames/obsidian-writing-goals)

Log output:

https://github.com/lynchjames/obsidian-writing-goals
App.openURL: Invalid URL
Script step completed.

v40 added a lot of parameter checking to values passed to Javascript function to avoid cases where unexpected values can produce bad results and or crashes.

You are not passing in a string, but a String object, which is not a valid parameter. It should be a raw string datatype. This worked before because Javascript would try to coerce it to a string for you, but that is no longer allowed. Just return the string as returned by the match call by removing your new String wrapper.

// change...
const URL = new String (testUrl[0]);
// to this...
const URL = testUrl[0];
1 Like

Presto. Thanks for the quick solution!

1 Like