From e1645805e637fc7d7cd60c2ae3d51af6f361305b Mon Sep 17 00:00:00 2001 From: Reza Soltani Date: Fri, 22 Dec 2023 19:14:06 +0330 Subject: [PATCH] fix getTypeIndexURL --- src/TypeIndexHelper.ts | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/src/TypeIndexHelper.ts b/src/TypeIndexHelper.ts index e890ae9..0f8c2cb 100644 --- a/src/TypeIndexHelper.ts +++ b/src/TypeIndexHelper.ts @@ -80,11 +80,7 @@ export class TypeIndexHelper { const profileMe = await this.getMeProfile(webId, fetch); const typeIndexPredicate = TypeIndexHelper.getTypeIndexPredicate(isPrivate); - const typeIndexFileName = TypeIndexHelper.getTypeIndexFileName(isPrivate); - const typeIndexUrl = TypeIndexHelper.getTypeIndexURL( - webId, - typeIndexFileName - ); + const typeIndexUrl = TypeIndexHelper.getDefaultTypeIndexURL(webId, isPrivate); if (profileMe) { let typeIndex = getNamedNode(profileMe, typeIndexPredicate); @@ -107,8 +103,8 @@ export class TypeIndexHelper { return namedNode(typeIndexUrl); } else { - const typeIndexDS = await this.createTypeIndex(fetch, typeIndexUrl); - const profileDS = await getSolidDataset(webId, { fetch: fetch }); + await this.createTypeIndex(fetch, typeIndexUrl); + const profileDS = await getSolidDataset(webId, { fetch }); const profileMeThing = buildThing(createThing({ name: "me" })) .addNamedNode(typeIndexPredicate, namedNode(typeIndexUrl)) @@ -240,20 +236,6 @@ export class TypeIndexHelper { } catch (error) { } } - /** - * Returns the name of the typeIndexe file based on the isPrivate flag. - * - * @param isPrivate - Whether the typeIndexe file should be private or public. - * @returns The name of the typeIndexe file - either "privateTypeIndex" or "publicTypeIndex". - * @internal - */ - public static getTypeIndexFileName( - isPrivate: boolean - ): "privateTypeIndex" | "publicTypeIndex" { - return isPrivate ? "privateTypeIndex" : "publicTypeIndex"; - } - - /** * Returns the predicate to use for the typeIndexe based on whether it is private or public. * @@ -270,14 +252,14 @@ export class TypeIndexHelper { * Generates the URL for the given user's typeIndexe file. * * @param webId - The user's WebID URL - * @param typeIndexFileName - The name of the typeIndexe file + * @param isPrivate - Whether the typeIndexe is private or public. * @returns The full URL for the typeIndexe file in the user's /settings/ folder * @internal */ - public static getTypeIndexURL( + public static getDefaultTypeIndexURL( webId: string, - typeIndexFileName: string + isPrivate: boolean, ): string { - return `${webId.split("/profile")[0]}/settings/${typeIndexFileName}.ttl`; + return `${webId.split("/profile")[0]}/settings/${isPrivate ? "privateTypeIndex" : "publicTypeIndex"}.ttl`; } } \ No newline at end of file