Add check for invalid ID

pull/77/head
MillenniumEarl 2021-03-10 10:20:05 +01:00
parent c5d449d411
commit c0a9718489
2 changed files with 6 additions and 0 deletions

View File

@ -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);

View File

@ -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();