Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gw): URI router for Web API navigator.registerProtocolHandler #7802

Merged
merged 5 commits into from Jan 14, 2021

Commits on Jan 14, 2021

  1. feat: support requests from registerProtocolHandler

    This commit adds support for requests produced by navigator.registerProtocolHandler on gateways. Now one can register `dweb.link` as an URI handler for `ipfs://`:
    
    ```
    navigator.registerProtocolHandler('ipfs', 'https://dweb.link/ipfs/?uri=%s', 'ipfs resolver')
    ```
    
    Then opening `ipfs://QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR` will produce an HTTP GET call to:
    
    ```
    https://dweb.link/ipfs?uri=ipfs%3A%2F%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
    ```
    
    The query parameter `uri` will now be parsed and the given content identifier resolved via:
    
    `https://dweb.link/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR`
    dennis-tra authored and lidel committed Jan 14, 2021
    Configuration menu
    Copy the full SHA
    36368ee View commit details
    Browse the repository at this point in the history
  2. fix: ?uri= url-decode and preserve query

    This makes ?uri= param able to process URIs passed by web browsers
    https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler
    lidel committed Jan 14, 2021
    Configuration menu
    Copy the full SHA
    3de5b14 View commit details
    Browse the repository at this point in the history
  3. refactor: remove redundant urlescape

    URL.Query() will already decode the query parameters
    lidel committed Jan 14, 2021
    Configuration menu
    Copy the full SHA
    abb25a1 View commit details
    Browse the repository at this point in the history
  4. test: sharness for ?uri= router

    Additional tests to ensure there are no regressions, as this will be
    used by browser vendors in the future.
    lidel committed Jan 14, 2021
    Configuration menu
    Copy the full SHA
    cdad394 View commit details
    Browse the repository at this point in the history
  5. test: cover 2 remaining lines

    lidel committed Jan 14, 2021
    Configuration menu
    Copy the full SHA
    a0f90d3 View commit details
    Browse the repository at this point in the history