URL String Get Directory
javascript, jquery
Solution
var resultUrl = url.substring(0, url.lastIndexOf("/") + 1);
Working jsfiddle here
Problem
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/"; ```