Skip to content

Commit

Permalink
Fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
jihchi committed Sep 7, 2024
1 parent 3e40a64 commit 44639ad
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/views/services.oembed.js
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;
};

Expand Down

0 comments on commit 44639ad

Please sign in to comment.