Textarea HTML Editor tool - URL path file://

The below code has something to do with it....the html editor that I am using, if you enter a http URL, no problem it works. But for some reason if I enter an internal URL like this: file://H:\folder name

I always get the result as: "file:///H:/folder name"  no matter what, it keeps adding an extra forward slash " / " in front of the file://. Is there anything wrong with the regular expression below? file:/// does not work, in outlook the file link works only with 2 slash file://H:/

try the demo here you'll see: http://www.openwebware.com/wysiwyg/demo.shtml
getDocumentPathOfUrl: function(url) {
		var path = null;
		
		// if local file system, convert local url into web url
		url = url.replace(/file:\/\//gi, "file://");
		url = url.replace(/\\/gi, "\/");
		var pos = url.lastIndexOf("/");
		if(pos != -1) {
			path = url.substring(0, pos + 1);
		}
		return path;
	},
	
	/**
	 * Get the documents url, convert local urls to web urls
	 * 
	 * @param {DOMElement} doc Document which is used to get the url
	 */
	getDocumentUrl: function(doc) {
		// if local file system, convert local url into web url
		var url = doc.URL;
		url = url.replace(/file:\/\//gi, "file://");
		url = url.replace(/\//gi, "/");
		return url;
	},

Open in new window

clubzoneAsked:
Who is Participating?
 
amit_gCommented:
It is doing it correctly. In the local file URLs three slashes are needed. See the explanation.

http://blogs.msdn.com/ie/archive/2006/12/06/file-uris-in-windows.aspx
0
 
clubzoneAuthor Commented:
The thing is I use this with my work Intranet server and 3 slashes does not work, people needs to link to Internal file server, therefore it has to be set to file://D:\folname\thisfile.xls

even if I enter 2 // instead of 3 manually, it automatically puts it back to 3 slashes, why is it doing this, and how to fix it for my behalf.
0
 
amit_gCommented:
What o/s and browser are you targeting (for the client not the web server)?
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
clubzoneAuthor Commented:
windows XP Pro and IE6.0
0
 
clubzoneAuthor Commented:
well it seems to work now! the server has to match exactly. the lower and upper case made the difference. if I were to type in file:///h:/intranet instead of file:///H:/INTRANET it would not work, if you match it exactly it works, I did not know lower uppercase made the difference? strange.
0
 
clubzoneAuthor Commented:
Thanks for the link.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.