Skip to content

Commit

Permalink
adapter ipns url and ipfs url
Browse files Browse the repository at this point in the history
  • Loading branch information
XueMoMo committed Jul 2, 2024
1 parent 2c6305d commit 81c8a76
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
13 changes: 13 additions & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
IPFS hash of the deployment:
CIDv1: bafybeidsucvs434zirxhib6npfzfqg4jagv6xkccfxjz3gmegib2bu36zq

The latest release is always mirrored at [crustfiles.io](https://crustfiles.io).


Your Uniswap settings are never remembered across different URLs.

IPFS gateways:

- https://bafybeidsucvs434zirxhib6npfzfqg4jagv6xkccfxjz3gmegib2bu36zq.ipfs.dweb.link/
- https://bafybeidsucvs434zirxhib6npfzfqg4jagv6xkccfxjz3gmegib2bu36zq.ipfs.cf-ipfs.com/
- [ipfs://QmW47HPC4SPLcqU9J19iTWNzjsqyaTmbUyhxUyNLcPNqhu/](ipfs://QmW47HPC4SPLcqU9J19iTWNzjsqyaTmbUyhxUyNLcPNqhu/)
27 changes: 20 additions & 7 deletions lib/hooks/useConfigDomain.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import { useEffect } from 'react'
import { useEffect } from "react";

export const DomainRef = {
value: 'crustfiles.io',
}
value: "crustfiles.io",
};

const supportDomain = ["crustfiles.io", "crustfiles.com", "crustfiles.xyz"];

export const getAvilableDomain = () => {
if (location.hostname == "localhost") return supportDomain[0];
if (location.hostname.match(/^\d+\.\d+\.\d+\.\d+$/)?.length == 1) return supportDomain[0];
const domains = location.hostname.split(".");
let domain = domains.slice(-2).join(".");
if (domains[1] == "ipns") {
domain = domains[0].replaceAll("-", ".");
}
if (supportDomain.includes(domain)) {
return location.hostname;
}
return supportDomain[0];
};
export function useConfigDomain() {
useEffect(() => {
if (location.hostname !== 'localhost' && location.hostname !== DomainRef.value) {
DomainRef.value = location.hostname
}
}, [])
DomainRef.value = getAvilableDomain();
}, []);
}
2 changes: 1 addition & 1 deletion lib/useUpload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function useUpload(user: WrapLoginUser, options: Options): UseUpload {

setUpState({ progress: Math.round(percent * 99), up: true });
},
params: { pin: true },
params: { pin: true, 'cid-version': 1, },
url: `${UpEndpoint}/api/v0/add`
});

Expand Down

0 comments on commit 81c8a76

Please sign in to comment.