Add check for invalid ID
parent
c5d449d411
commit
c0a9718489
|
@ -101,6 +101,9 @@ export default class Post implements ILazy {
|
||||||
// Check login
|
// Check login
|
||||||
if (!shared.isLogged) throw new UserNotLogged(USER_NOT_LOGGED);
|
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
|
// Fetch HTML page containing the post
|
||||||
const url = new URL(this.id.toString(), urls.POSTS).toString();
|
const url = new URL(this.id.toString(), urls.POSTS).toString();
|
||||||
const response = await fetchHTML(url);
|
const response = await fetchHTML(url);
|
||||||
|
|
|
@ -230,6 +230,9 @@ export default class Thread implements ILazy {
|
||||||
// Check login
|
// Check login
|
||||||
if (!shared.isLogged) throw new UserNotLogged(USER_NOT_LOGGED);
|
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
|
// Prepare the url
|
||||||
this._url = new URL(this.id.toString(), urls.THREADS).toString();
|
this._url = new URL(this.id.toString(), urls.THREADS).toString();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue