Is it possible to set the url parameter in ipfs? Or is there an alternative to that?

Is it possible to set the url parameter in ipfs? Or is there an alternative to that?

Are you referring to URL parameters when fetching from IPFS Gateways, e.g. https://bafybeibml5uieyxa5tufngvg7fgwbkwvlsuntwbxgtskoqynbt7wlchmfm.ipfs.dweb.link, or when using native ipfs URLs, e.g. ipfs://bafybeibml5uieyxa5tufngvg7fgwbkwvlsuntwbxgtskoqynbt7wlchmfm?

IPFS Gateways support three query parameters, which you can read more about here: specs/PATH_GATEWAY.md at main · ipfs/specs · GitHub

I need to know how to set parameters for native ipfs URLs.

What are you trying to use parameters for? Because ultimately, it’s a question of the implementation that handles the ipfs:// URL.

See this doc (the closest thing we have to a spec) for the most up-to-date resource on how IPFS addressing is defined: in-web-browsers/ADDRESSING.md at master · ipfs/in-web-browsers · GitHub

1 Like

I am trying to use the url parameter for javascript.
Thanks. I was able to execute it.

I’d be curious to hear more about how you’ve used it, in case others stumble upon this

I use it this way.

<!DOCTYPE html>
<html>
<head>
  <title>URL Parameter Example</title>
  <script>
    const urlParams = new URLSearchParams(window.location.search);

    const value = urlParams.get('parameter');

    window.onload = function() {
      document.getElementById('result').innerHTML = value;
    };
  </script>
</head>
<body>
  <h1>URL Parameter Test</h1>
  <p>Add parameters and values to url.<br>
    For example '?parameter=aaa'</p>
  <p>Parameter value: <span id="result"></span></p>
</body>
</html>

Example.
ipfs://bafybeif2emss3qnv3yl3iyeojjuswly2zrlcv6dr4sgdggyvvhq3y4dpcy/?parameter=aaa

2 Likes