My needs:
Open an external url in my vscode extension. The url to open contains a search param: redirect_uri=/client-redirect?client_type=vscode
Problem encountered:
I open the url by:
env.openExternal(Uri.parse(url))
Encode the value part or not, open the url, the redirect_uri part in address bar is always redirect_uri=/client-redirect%253Fclient_type=vscode. If I click 'Copy' instead 'Open', the redirect_uri part is always redirect_uri=/client-redirect%3Fclient_type=vscode
The ? was encoded once or twice but / and = was not encoded. For comparsion, the correct encoding should be redirect_uri=%2Fclient-redirect%3Fclient_type%3Dvscode
I think the core problem is the Uri.parse and ext.OpenEnternal re-parse the url even it's already correctly encoded. I need a solution to open url directly without extra parse.
Temp solutions I found:
I can use open or system command instead of openExternal:
open(manullyEncodedUrl); // open moudle from node
// or use system command
// openUrlByCommand(manullyEncodedUrl); // open by 'open url' or 'start url' or 'xdg-open url' depends on os
The temp solutions can fullfill my needs for now, but the env.openExternal is still the ideal approach if possible, since it's offical and contains some special security check and logics for certain circumstances. So the final problem is: Is it possible to open such url by env.openExternal correctly
Uri.parse, have you triedUri.from(creating a URI from its component parts)?Uri.fromreceives aquerystring param which is the whole query part, no different withUri.parsein parsing query.