JSFiddle - React, Tailwind, and code Playground

by stevenkaspar

JavaScript

var path = '/var/www/site_manager/site_manager_app_sk/../webdav/abercrombie--helix.custhelp.com/cp/customer/assets/themes/scss/scss/all.scss';
var theme_match = path.match(/\/(([a-z]|[A-Z]|[0-9]|\_|\.|\-)+\/)+cp\/customer\/assets\/themes\/([a-z]|[A-Z]|\_)+\/scss\//);
if(theme_match){
    console.log('theme match');
    console.log({
        scss_source: theme_match[0] + 'all.scss',
        css_location: theme_match[0].split('scss/').slice(0,-1).join('scss/') + 'site.css'
    });
}

var path = '/var/www/site_manager/site_manager_app_sk/../webdav/abercrombie--helix.custhelp.com/cp/customer/development/widgets/custom/scss/SampleWidget/1.0/base.scss';
// check if we are saving from a widget
var widget_match = path.match(/\/(([a-z]|[A-Z]|[0-9]|\_|\.|\-)+\/)+cp\/customer\/development\/widgets\/custom\/(([a-z]|[A-Z]|[0-9]|\_)+\/){2}([0-9]\.[0-9])\//);
if(widget_match) {
    console.log('widget match');
    console.log({
        scss_source: path,
        css_location: path.split('.scss').slice(0,-1).join('.scss') + '.css'
    });
}