From 44639adbd569cacb6b96567870270935b562a0f4 Mon Sep 17 00:00:00 2001 From: jihchi Date: Sat, 7 Sep 2024 10:30:19 +0300 Subject: [PATCH] Fix broken test --- src/views/services.oembed.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/views/services.oembed.js b/src/views/services.oembed.js index 19c94ae..6511f0d 100644 --- a/src/views/services.oembed.js +++ b/src/views/services.oembed.js @@ -1,10 +1,12 @@ const createDebug = require('debug'); -const { pathToRegexp } = require('path-to-regexp'); +const { match } = require('path-to-regexp'); const openMermaidPage = require('openMermaidPage'); const renderSVG = require('renderSVG'); const debug = createDebug('app:services:oembed'); +const matchImgEncodedCode = match('/img/:encodedCode'); + const parseAndValidateURL = (inputURL) => { let url; @@ -27,14 +29,13 @@ const parseAndValidateURL = (inputURL) => { }; const getEncodedCodeFromURL = ({ pathname }) => { - const regexp = pathToRegexp('/img/:encodedCode'); - const matches = regexp.exec(pathname); + const matches = matchImgEncodedCode(pathname); if (!matches) { throw new Error('URL pathname supported: /img/:code, /svg/:code'); } - const [, encodedCode] = matches; + const { params: { encodedCode } } = matches; return encodedCode; };