From 81f4e0bd2dbd9fb22c19124c9e0ae5665f177d02 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Tue, 9 Aug 2022 07:38:58 +0700 Subject: [PATCH] fix(Client): Invalid URL + client is undefined fixed #243 --- src/client/Client.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/client/Client.js b/src/client/Client.js index 0f3a443..6f45858 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -817,6 +817,7 @@ class Client extends BaseClient { * @returns {Promise} */ async authorizeURL(url, options = {}) { + const reg = /^https:\/\/discord.com\/(api\/)*oauth2\/authorize(\W+)/gim; const checkURL = () => { try { // eslint-disable-next-line no-new @@ -833,10 +834,10 @@ class Client extends BaseClient { }, options, ); - if (!url || !checkURL() || !url.startsWith('https://discord.com/oauth2/authorize?')) { + if (!url || !checkURL() || !reg.test(url)) { throw new Error('INVALID_URL', url); } - await this.client.api.oauth2.authorize[`?${url.replace('https://discord.com/oauth2/authorize?', '')}`].post({ + await this.api.oauth2.authorize[`?${url.replace(reg, '')}`].post({ data: options, }); return true;