diff --git a/src/scripts/classes/mapping/post.ts b/src/scripts/classes/mapping/post.ts index f9dfaaf..c8f9da5 100644 --- a/src/scripts/classes/mapping/post.ts +++ b/src/scripts/classes/mapping/post.ts @@ -101,6 +101,9 @@ export default class Post implements ILazy { // Check login if (!shared.isLogged) throw new UserNotLogged(USER_NOT_LOGGED); + // Check ID + if (!this.id && this.id < 1) throw new Error("Invalid post ID"); + // Fetch HTML page containing the post const url = new URL(this.id.toString(), urls.POSTS).toString(); const response = await fetchHTML(url); diff --git a/src/scripts/classes/mapping/thread.ts b/src/scripts/classes/mapping/thread.ts index 40d9a87..e061a1f 100644 --- a/src/scripts/classes/mapping/thread.ts +++ b/src/scripts/classes/mapping/thread.ts @@ -230,6 +230,9 @@ export default class Thread implements ILazy { // Check login if (!shared.isLogged) throw new UserNotLogged(USER_NOT_LOGGED); + // Check ID + if (!this.id && this.id < 1) throw new Error("Invalid thread ID"); + // Prepare the url this._url = new URL(this.id.toString(), urls.THREADS).toString();