fix name and identifier parsing

This commit is contained in:
PhilReact 2025-03-26 22:47:20 +02:00
parent 4ea8ee87e3
commit 9eb467ad72
4 changed files with 7 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{
"name": "qapp-core",
"version": "1.0.10",
"version": "1.0.11",
"description": "Qortal's core React library with global state, UI components, and utilities",
"main": "dist/index.js",
"module": "dist/index.mjs",

View File

@ -28,7 +28,7 @@ export const usePublish = (
const [hasResource, setHasResource] = useState<boolean | null>(null);
const fetchRawData = useCallback(async (item: QortalGetMetadata) => {
const url = `/arbitrary/${item?.service}/${item?.name}/${item?.identifier}?encoding=base64`;
const url = `/arbitrary/${item?.service}/${encodeURIComponent(item?.name)}/${encodeURIComponent(item?.identifier)}?encoding=base64`;
const res = await fetch(url);
const data = await res.text();
if(returnType === 'BASE64'){
@ -104,7 +104,7 @@ export const usePublish = (
resourceExists: true
}
}
const url = `/arbitrary/resources/search?mode=ALL&service=${metadataProp?.service}&limit=1&includemetadata=true&reverse=true&excludeblocked=true&name=${metadataProp?.name}&exactmatchnames=true&offset=0&identifier=${metadataProp?.identifier}`;
const url = `/arbitrary/resources/search?mode=ALL&service=${metadataProp?.service}&limit=1&includemetadata=true&reverse=true&excludeblocked=true&name=${encodeURIComponent(metadataProp?.name)}&exactmatchnames=true&offset=0&identifier=${encodeURIComponent(metadataProp?.identifier)}`;
const responseMetadata = await fetch(url, {
method: "GET",
headers: {

View File

@ -88,7 +88,7 @@ export const useResources = (retryAttempts: number = 2) => {
let metadata
try {
if (includeMetadata) {
const url = `/arbitrary/resources/search?mode=ALL&service=${item?.service}&limit=1&includemetadata=true&reverse=true&excludeblocked=true&name=${item?.name}&exactmatchnames=true&offset=0&identifier=${item?.identifier}`;
const url = `/arbitrary/resources/search?mode=ALL&service=${item?.service}&limit=1&includemetadata=true&reverse=true&excludeblocked=true&name=${encodeURIComponent(item?.name)}&exactmatchnames=true&offset=0&identifier=${encodeURIComponent(item?.identifier)}`;
const response = await fetch(url, {
method: "GET",
headers: {
@ -109,7 +109,7 @@ export const useResources = (retryAttempts: number = 2) => {
res = await requestQueueProductPublishes.enqueue(
(): Promise<string> => {
return getArbitraryResource(
`/arbitrary/${item?.service}/${item?.name}/${item?.identifier}?encoding=base64`,
`/arbitrary/${item?.service}/${encodeURIComponent(item?.name)}/${encodeURIComponent(item?.identifier)}?encoding=base64`,
key
);
}
@ -132,7 +132,7 @@ export const useResources = (retryAttempts: number = 2) => {
return await requestQueueProductPublishesBackup.enqueue(
(): Promise<string> => {
return getArbitraryResource(
`/arbitrary/${item?.service}/${item?.name}/${item?.identifier}?encoding=base64`,
`/arbitrary/${item?.service}/${encodeURIComponent(item?.name)}/${encodeURIComponent(item?.identifier)}?encoding=base64`,
key
);
}

View File

@ -38,7 +38,7 @@ export const useAuthStore = create<AuthState>((set) => ({
// Methods
setUser: (user) =>
set({ address: user.address, publicKey: user.publicKey, name: user.name || null, avatarUrl: !user?.name ? null : `/arbitrary/THUMBNAIL/${user.name}/qortal_avatar?async=true` }),
set({ address: user.address, publicKey: user.publicKey, name: user.name || null, avatarUrl: !user?.name ? null : `/arbitrary/THUMBNAIL/${encodeURIComponent(user.name)}/qortal_avatar?async=true` }),
setBalance: (balance) => set({ balance }),
setIsLoadingUser: (loading) => set({ isLoadingUser: loading }),
setIsLoadingBalance: (loading) => set({ isLoadingInitialBalance: loading }),