String to be used as-is.
String in which PopClip will replace +
characters with %20
before use.
const exampleUrl=new URL("https://example.com/path");
exampleUrl.searchParams.set("q","query with spaces");
print(exampleUrl.href)); // this will print "https://example.com/path?q=query+with+spaces"
popclip.openUrl(exampleUrl); // this will open "https://example.com/path?q=query%20with%20spaces"
The
UrlObject
type is used for passing URL parameters into some methods. It can be either an object with aurl
property, or an object with anhref
property.url
property, the value of that property is used as the URL.href
property, the that string is first processed to replace all+
with%20
and then used as the URL.url
andhref
properties, theurl
property is used.The rationale for this is that URL objects in JavaScript provide the
href
property, with spaces encoded as+
. Most modern APIs expect spaces to be encoded as%20
, so this behaviour allows URL objects to be passed in to methods that want a url, without needing to manually re-encode spaces.