Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Handling URL Scheme For URL With Double Slash

Handling URL Scheme For URL With Double Slash

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Ghazanfar Ali
    wrote on 10 May 2022, 06:26 last edited by
    #1

    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.

    1. mylink:username:password@domain*
    2. 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

    Screenshot 2022-05-10 at 11.13.22 AM.png

    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.

    Screenshot 2022-05-10 at 11.12.55 AM.png

    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.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 10 May 2022, 10:56 last edited by
      #2

      @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 :)

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Ghazanfar Ali
        wrote on 10 May 2022, 11:20 last edited by
        #3

        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.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 10 May 2022, 11:28 last edited by
          #4

          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.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 10 May 2022, 19:07 last edited by
            #5

            Hi,

            How did you register your custom URL scheme ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • G Offline
              G Offline
              Ghazanfar Ali
              wrote on 11 May 2022, 04:56 last edited by
              #6

              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>
              
              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 11 May 2022, 20:28 last edited by
                #7

                If memory serves well, you should use QDesktopServices to register a custom handler for your URL scheme.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  Ghazanfar Ali
                  wrote on 30 Aug 2022, 07:59 last edited by
                  #8

                  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.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    Ghazanfar Ali
                    wrote on 30 Aug 2022, 08:09 last edited by
                    #9

                    There is a new observation I have the Test URLs i.e.

                    1. mylink:username:password@domain*
                    2. 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.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 30 Aug 2022, 19:22 last edited by
                      #10

                      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.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved