I have a string which displays a path. The issue is sometimes the path contains the same text more than once after the '/' as shown below. I want to ensure that if that happens, the content is removed. How can I solve this?
// A $( document ).ready() block.
$( document ).ready(function() {
console.log( "ready!" );
const trimEnd = str => str.endsWith('/') ? str.slice(0, -1) :
str;
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="hidden" name="FilePath" id="FilePath" value="/content/enforced/12063-CC-125/12063-CC-125/">