Handling URL Scheme For URL With Double Slash
-
I am trying to process the Custom URL Scheme, I am able to process them but there are two different formats for specifying the Custom URLs i.e.
- mylink:username:password@domain*
- mylink://username:password@domain*
Here you can see that there is an additional Double Slash after the Custom Scheme in Option-2. The application gets triggered for Both URL and I am able to get the Event in
bool eventFilter(QObject *obj, QEvent *event)
But the issue is with the URL Object in side this QEvent, For the Option-1 I am able to get the complete contents when I print the URL on Console i.e. mylink:username:password@domain* as you can see in the following debug screenshot
But when the application is triggered for the Option-2, the URL seems to be truncating the Domain Part and when I print the URL is only printing the partial data, as you can see in following screenshot.
Can you please provide your feedback on this, and how can I process both URL Types, as I am not able to get the complete data in eventFilter for the Option-2.
Thanking in Advance,
Regards,
Ghazanfar. -
@Ghazanfar-Ali said in Handling URL Scheme For URL With Double Slash:
mylink://username:password@domain*
This is an url with the schema 'mylink://' - if you think other then ask the ISO standard :)
-
The issue is with this URL Scheme i.e. containing the // Double Slash, the QT eventFilter is not able to process it, where as when that same URL is without // i.e. mylink:username:password@domain*, its able to process it and provide the complete info.
-
I don't see what the event filter has to do with this but as I said - 'foo://' is a schema definition. See e.g. QUrl documentation or any other spec which describes how a url is built.
-
Hi,
How did you register your custom URL scheme ?
-
via info.plist
<key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleTypeRole</key> <string>Viewer</string> <key>CFBundleURLName</key> <string>my.test.links.csc</string> <key>CFBundleURLSchemes</key> <array> <string>mylink</string> </array> </dict> </array>
-
If memory serves well, you should use QDesktopServices to register a custom handler for your URL scheme.
-
Registering the custom handler using QDesktopServices, only covers the part when Application Tries to open the url with the scheme registered in Handler. It does nothing for the URLs with the same scheme clicked outside the application e.g. when the URL with the registered scheme is opened in the Browser.
-
There is a new observation I have the Test URLs i.e.
- mylink:username:password@domain*
- mylink://username:password@domain*
Both ending with *, if I remove the * from the end, both URLs seems to be loaded properly to some extent i.e.
With URL-1, only the Path variable of QUrl holds this "username:password@domain" and scheme holds the scheme i..e. mylink
With URL-2, the variables in QUrl seems to have all the required data i.e. Username, Password, Host, Scheme etc. except the Path property is empty. -
AFAIK, a
*
is not a valid char in a FQDN hence the result you get.As for the scheme, from memory it requires // to be a valid scheme.