JSFiddle - React, Tailwind, and code Playground

by neonDog

JavaScript

let path = '/gb/poo/foo/bar';
path = '/preview/theme/agency/gb/poo/foo/bar';
let isPreview = true;

let newPath = [];

const pathArr = path.split('/');
//Slice depends upon if a preview url is accessed
return pathArr.slice(isPreview ? 4 : 1);