Skip to content

Commit 3ed7743

Browse files
committed
Edits
1 parent b395dba commit 3ed7743

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

docs/how-to/detect-ipfs-on-web.md

+25-24
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
# Discover IPFS content from web2
1+
---
2+
title: Discover IPFS content from Web2
3+
description: Learn how to add support for content-addressed IPFS resources in web browsers and other user agents.
4+
---
25

3-
Below is the suggested heuristic for detecting content-addressed resources on the web, and presenting additional user interface for interacting with that content.
6+
# Discover IPFS content from Web2
47

5-
The goal of this page is to provide some suggestions and best practices for web browsers and other [user agents](https://en.wikipedia.org/wiki/User_agent) that are interested in adding support for [content-addressed resources on the Web](/how-to/address-ipfs-on-web).
8+
The goal of this page is to provide some suggestions and best practices for Web 2 web browsers and other [user agents](https://en.wikipedia.org/wiki/User_agent) that are interested in adding support for [content-addressed resources](/how-to/address-ipfs-on-web).
69

710
## Detecting content-addressed resources
811

9-
In many cases IPFS resources can be detected just by looking at the URI, especially if it is an HTTP URL pointing at a public gateway. This allows a browser to upgrade the transport protocol to IPFS, and remove the need for sending an HTTP request to a remote server.
12+
In many cases, IPFS resources can be detected just by looking at the URI, especially if it is an HTTP URL pointed at a public gateway. This allows a browser to upgrade the transport protocol to IPFS, and removes the need to send an HTTP request to a remote server.
1013

11-
The high level heuristic is to check, in order:
12-
- Does the `URL` follow [path or subdomain gateway](/how-to/address-ipfs-on-web/) convention?
13-
- If not, does [DNSLink](/concepts/dnslink/) with an IPFS path exist for `URL.hostname`?
14+
### Methodology
1415

15-
If any of the above is true, a user agent should be able to find a content path that can be used for data retrieval over IPFS. See the illustration below.
16+
To determine if a resource is an IPFS resource, answer the following questions in order:
17+
18+
1. Does the `URL` follow [path or subdomain gateway](/how-to/address-ipfs-on-web/) convention?
19+
1. If not, does [DNSLink](/concepts/dnslink/) with an IPFS path exist for `URL.hostname`?
20+
21+
If you answered yes to either of the above questions, a user agent should be able to find a content path that can be used for data retrieval over IPFS, as described in the illustration below:
1622

1723
```mermaid
1824
flowchart TD
@@ -77,7 +83,9 @@ flowchart TD
7783
PathFromHeader --> PotentialContentPath
7884
```
7985

80-
## What to do with detected paths?
86+
## What to do with detected paths
87+
88+
What you do with the detected IPFS resource path depends on the type of path.
8189

8290
### Immutable `/ipfs/cid/..`
8391

@@ -101,27 +109,20 @@ flowchart TD
101109

102110
## FAQ
103111

104-
- What if a browser does not support `ipfs://` and `ipns://` natively?
105-
- Implementation can use a [HTTP Gateway](/reference/http/gateway/) as a fallback: convert them to `//gatewayhost/ipxs/id/..` paths, or leverage the built-in URI router at `//gatewayhost/ipfs/?uri=%s`
106-
- Why should `?query` or `#hash` from the original HTTP URL be preserved?
107-
- Link could point at specific `#section` of a longer article. It is also common for JS running on a page to use `?query` and `#hash` for navigation and ad-hoc storage for some state.
108-
- Should user agent redirect when URL does not match gateway convention, `URL.hostname` does not have a valid DNSLink, but `X-Ipfs-Path` is present in HTTP response AND points at immutable `/ipfs/cid`?
109-
- This is an edge case, and we've seen that it is often a misconfiguration caused by invalid/missing DNSLink that could lead to bad UX when automatic redirect is involved: user ends up on immutable copy of a website, bookmark it or keep tab open, and miss updates when DNSLink setup is fixed.
110-
- It is suggested to not redirect this edge case, or provide a setting that controls this type of redirect. Usually, showing "Open via IPFS" in the user interface is enough for this case.
112+
**What if a browser does not support `ipfs://` and `ipns://` natively?** Implementations can use an [HTTP Gateway](/reference/http/gateway/) as a fallback, convert ththe path to `//gatewayhost/ipxs/id/..`-type paths, or leverage the built-in URI router at `//gatewayhost/ipfs/?uri=%s`
113+
114+
**Why should `?query` or `#hash` from the original HTTP URL be preserved?** The link could point at specific `#section` of a longer article. It is also common for JavaScript running on a page to use the `?query` and `#hash` for navigation and ad-hoc storage of some state.
115+
116+
**Should a user agent redirect when the URL does not match gateway convention, `URL.hostname` does not have a valid DNSLink, but `X-Ipfs-Path` is present in HTTP response AND points at an immutable `/ipfs/cid`?** This is an edge case, and we've seen that it is often a misconfiguration caused by an invalid or missing DNSLink that could lead to bad UX when automatic redirect is involved. The user ends up on an immutable copy of a website, bookmarks it or keeps tabs open, and misses updates when DNSLink setup is fixed. It is suggested to not redirect this edge case, or provide a setting that controls this type of redirect. Usually, showing "Open via IPFS" in the user interface is enough for this case.
111117

112118
## Implementation examples
113119

114120
### Brave
115121

116-
[IPFS is supported in Brave since 2021](https://brave.com/brave-integrates-ipfs/). Current features include `ipfs://` and `ipns://` URI support, ability to resolve them using a public or local gateway, opt-in Gateway and DNSLink redirects, and "Open via IPFS" button in the address bar:
122+
[Brave has supported IPFS since 2021](https://brave.com/brave-integrates-ipfs/). Current features include `ipfs://` and `ipns://` URI support, ability to resolve this type of address using a public / local gateway, opt-in Gateway and/or DNSLink redirects, and an **Open via IPFS** button in the address bar:
117123

118-
> ![Open via IPFS in Brave addressbar](https://user-images.githubusercontent.com/157609/110859368-9a0d7300-82bb-11eb-934d-4e38718dbacb.png)
124+
> ![Open via IPFS in Brave address bar](https://user-images.githubusercontent.com/157609/110859368-9a0d7300-82bb-11eb-934d-4e38718dbacb.png)
119125
120126
### IPFS Companion
121127

122-
Firefox and Chromium-based browsers such as Google Chrome, Microsoft Edge can be augumented with [IPFS Companion](/install/ipfs-companion/) browser extension.
123-
124-
It provides detection of IPFS resources, redirect functionality, and a handy UI:
125-
126-
> ![Quick runthrough of basic IPFS Companion features](https://gateway.ipfs.io/ipfs/QmSsGphTN1eWMhkFFNFb23jWTXyhNbo47PF9FbmC6ZaRNg)
127-
128+
Firefox and Chromium-based browsers such as Google Chrome or Microsoft Edge can be augumented with [IPFS Companion](/install/ipfs-companion/) browser extension, which allows them to detect IPFS content.

0 commit comments

Comments
 (0)