From 025cd12abadc6bf7494d48153e2d69159e001341 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Wed, 8 Mar 2023 14:15:06 +0100 Subject: [PATCH] feat: Remove query-string dep --- package.json | 1 - src/claimDefinitions/matrix.js | 10 +++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 95712b2..03034e8 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "irc-upd": "^0.11.0", "merge-options": "^3.0.3", "openpgp": "^5.5.0", - "query-string": "^6.14.1", "valid-url": "^1.0.9", "validator": "^13.5.2" }, diff --git a/src/claimDefinitions/matrix.js b/src/claimDefinitions/matrix.js index 54806af..027ecbb 100644 --- a/src/claimDefinitions/matrix.js +++ b/src/claimDefinitions/matrix.js @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ const E = require('../enums') -const queryString = require('query-string') const reURI = /^matrix:u\/(?:@)?([^@:]*:[^?]*)(\?.*)?/ @@ -25,14 +24,15 @@ const processURI = (uri) => { return null } - const params = queryString.parse(match[2]) - const paramRoomId = `${params['org.keyoxide.r'][0] !== '!' ? '!' : ''}${params['org.keyoxide.r']}` - const paramEventId = `${params['org.keyoxide.e'][0] !== '$' ? '$' : ''}${params['org.keyoxide.e']}` + const params = new URLSearchParams(match[2]) - if (!('org.keyoxide.e' in params && 'org.keyoxide.r' in params)) { + if (!(params.has('org.keyoxide.e') && params.has('org.keyoxide.r'))) { return null } + const paramRoomId = `${params.get('org.keyoxide.r')[0] !== '!' ? '!' : ''}${params.get('org.keyoxide.r')}` + const paramEventId = `${params.get('org.keyoxide.e')[0] !== '$' ? '$' : ''}${params.get('org.keyoxide.e')}` + const profileUrl = `https://matrix.to/#/@${match[1]}` const eventUrl = `https://matrix.to/#/${paramRoomId}/${paramEventId}`