I have a string that contains a URL:
var url = "http://www.domain.com/Shared%20Documents/Test%20Plans/CC-12%20Test%20Plan.doc";
I am trying to get the url of the directory (ie remove the filename and keep the rest.) I realize that this is probably pretty simple but I can't seem to find anything on it.
Desired result:
var url = "http://www.domain.com/Shared%20Documents/Test%20Plans/";
var resultUrl = url.substring(0, url.lastIndexOf("/") + 1);
Working jsfiddle here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With