Hello,
I'm developing a plugin for embedding emaze into Nodebb, based on the codepen plugin by @a_5mith . It embeds a slideshow into your post when you paste a URL, just like it does for codepen frames.
I have it halfway working, however, when regex tries to grab the parameters and place them into the URL, the end result of the URL is this:
http://app.emaze.com/app/test
However, it needs to be this:
http://app.emaze.com/@AOZTORFL/test
For some reason, regex is grabbing the "app" portion of the URL and placing it where "@AOZTORFL" should be.
This results in an error. This is my javascript library:
(function(module) {
"use strict";
var one1 = "$3";
var two2 = "$2";
var cleanedString = one1.replace(/["']/g,"")
var cleanedString2 = two2.replace(/["']/g,"")
var emaze = {},
embed = '<iframe src="http://app.emaze.com/$1/$2" width="960px" height="540px" seamless webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe><a href="http://www.emaze.com" target="_blank"><img src="http://resources.emaze.com/mypres/css/images/embed.png" alt="Powered by emaze" style="margin: 5px; border: none;"></a>';
var pen = /<a href="(?:http?:\/\/)?(app)\.emaze\.com\/.+\/([\w\-_]+)">.+<\/a>/g;
emaze.parse = function(data, callback) {
if (!data || !data.postData || !data.postData.content) {
return callback(null, data);
}
if (data.postData.content.match(pen)) {
data.postData.content = data.postData.content.replace(pen, embed);
}
callback(null, data);
};
module.exports = emaze;
}(module));
I'm positive the problem is the way I'm writing the regex, however, I'm unsure of how to make it grab the "@AOZTORFL" portion of the URL correctly. May I please get some assistance with this?
Thank you.
Original Codepen plugin source code: https://github.com/a5mith/nodebb-plugin-codepen/blob/master/library.js