I'm getting a 500 in sapper (i think due to safari and firefox not support negative lookbehind assertions in js regex. But my try catch isn't stopping the problem.
import showdown from 'showdown';
const converter = new showdown.Converter({simplifiedAutoLink: true});
function parseContent(content) {ox()) && content.match(/http/)) {
let parsed;
try {
parsed = converter.makeHtml(content)
.replace(/(?<!https?.+)\/?a\/([^\s]*)/g, ` <a href="/a/$1">a/$1</a>`)
.replace(/\s*@(\w+)/g, ` <a href="/u/$1">@$1</a>`);
} catch(err) {
console.log(err);
parsed = converter.makeHtml(content)
.replace(/\s*@(\w+)/g, ` <a href="/u/$1">@$1</a>`);
}
return parsed;
}
export {
parseContent
}
How can I use a simpler regex for non-supporting browsers?