Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions user snippets/getURLFromEmail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Run a small snippet of JavaScript during a mabl flow/journey
*
* @param {object} mablInputs - Object containing mabl inputs such as variables (mablInputs.variables).
* Use mablInputs.variables.user for user defined variables
* (For example myVar may be accessed as mablInputs.variables.user.myVar)
*
* @param {function} callback - A callback function that must be called to complete
* the javascript step and provide a value to the following
* steps of the flow/journey. A return statement from this
* function call will not provide any results for use
* in the following steps in this flow or journey.
*/
function mablJavaScriptStep(mablInputs, callback) {

// Please set this value as for prefix of exract url
const urlPrefix = "https://daipresents.com";

// to \n
// const urlRegExp = "(" + urlPrefix + ".*)";

// to a space. The param use only +, &, =, ? so if you need add new charactor here
const urlRegExp = "(" + urlPrefix + "([+&=\?\/]|[a-z]|[A-Z]|[0-9])*)";

let regexp = new RegExp(urlRegExp);

let emailContents = document.getElementsByClassName('mabl-text-body')[0].value;
let url = emailContents.match(regexp)[1];

callback(url);
}