1
- const HASH_TO_TEST = 'Qmaisz6NMhDB51cCvNWa1GMS7LU1pAxdF4Ld6Ft9kZEP2a ' ;
2
- const SCRIPT_HASH = 'QmYHbXzTCbjavphzqrTe7zYYMW8HyeuMLNcLbqiUkj9TAH ' ;
1
+ const HASH_TO_TEST = 'bafybeifx7yeb55armcsxwwitkymga5xf53dxiarykms3ygqic223w5sk3m ' ;
2
+ const SCRIPT_HASH = 'bafybeietzsezxbgeeyrmwicylb5tpvf7yutrm3bxrfaoulaituhbi7q6yi ' ;
3
3
const HASH_STRING = 'Hello from IPFS Gateway Checker' ;
4
4
5
5
// checker is the program root, it contains all involved objects
@@ -112,6 +112,29 @@ Cors.prototype.onerror = function() {
112
112
} ;
113
113
// ////////////////////////////////////////////////////////////////////////////////////
114
114
115
+ // ////////////////////////////////////////////////////////////////////////////////////
116
+ // ORIGIN
117
+ let Origin = function ( parent ) {
118
+ this . parent = parent ;
119
+
120
+ this . tag = document . createElement ( "span" ) ;
121
+ this . tag . textContent = ' ORIGIN: 🕑 - ' ;
122
+ } ;
123
+
124
+ Origin . prototype . check = function ( ) {
125
+ const cidInSubdomain = this . parent . gateway . startsWith ( 'https://:hash.ipfs.' ) ;
126
+ if ( cidInSubdomain ) {
127
+ this . tag . textContent = ' ORIGIN: ✅ - ' ;
128
+ } else {
129
+ this . onerror ( ) ;
130
+ }
131
+ } ;
132
+
133
+ Origin . prototype . onerror = function ( ) {
134
+ this . tag . textContent = ' ORIGIN: ❌ - ' ;
135
+ } ;
136
+ // ////////////////////////////////////////////////////////////////////////////////////
137
+
115
138
// ////////////////////////////////////////////////////////////////////////////////////
116
139
// NODE
117
140
let Node = function ( parent , gateway , index ) {
@@ -125,6 +148,9 @@ let Node = function(parent, gateway, index) {
125
148
this . cors = new Cors ( this ) ;
126
149
this . tag . append ( this . cors . tag ) ;
127
150
151
+ this . origin = new Origin ( this ) ;
152
+ this . tag . append ( this . origin . tag ) ;
153
+
128
154
this . link = document . createElement ( "span" ) ;
129
155
this . link . textContent = gateway . replace ( ':hash' , HASH_TO_TEST ) ;
130
156
this . tag . append ( this . link ) ;
@@ -141,6 +167,7 @@ Node.prototype.check = function() {
141
167
this . checkingTime = performance . now ( ) ;
142
168
this . status . check ( ) ;
143
169
this . cors . check ( ) ;
170
+ this . origin . check ( ) ;
144
171
} ;
145
172
146
173
Node . prototype . checked = function ( ) {
@@ -149,7 +176,7 @@ Node.prototype.checked = function() {
149
176
150
177
let gatewayTitle = this . gateway . split ( ":hash" ) [ 0 ] ;
151
178
let gatewayAndHash = this . gateway . replace ( ':hash' , HASH_TO_TEST ) ;
152
- this . link . innerHTML = `<a title="${ gatewayTitle } "href="${ gatewayAndHash } " target="_blank">${ gatewayAndHash } </a>` ;
179
+ this . link . innerHTML = `<a title="${ gatewayTitle } " href="${ gatewayAndHash } #x-ipfs-companion-no-redirect" target="_blank">${ gatewayAndHash } </a>` ;
153
180
154
181
if ( ! this . tested ) {
155
182
let ms = ( performance . now ( ) - this . checkingTime ) . toFixed ( 2 ) ;
@@ -178,4 +205,3 @@ function checkGateways (gateways) {
178
205
fetch ( './gateways.json' )
179
206
. then ( res => res . json ( ) )
180
207
. then ( gateways => checkGateways ( gateways ) ) ;
181
-
0 commit comments