From 476a25e8a662270dfe5b37c560e4235f02b146e4 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 2 Feb 2012 12:59:41 -0800 Subject: uri validation moved to file io apis Signed-off-by: Ananya Sen --- js/io/system/coreioapi.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'js/io/system/coreioapi.js') diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index f4ab56b6..f0ca568f 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js @@ -983,6 +983,27 @@ exports.CoreIoApi = Montage.create(Component, { return retValue; } }, + + /*** + * checks for valid uri pattern + * also flags if Windows uri pattern and Unix uri patterns are mixed + */ + isValidUri:{ + value: function(uri){ + var isWindowsUri=false, isUnixUri=false,status=false; + if(uri !== ""){ + uri = uri.replace(/^\s+|\s+$/g,""); // strip any leading or trailing spaces + + //for local machine folder uri + isWindowsUri = /^([a-zA-Z]:)(\\[^<>:"/\\|?*]+)*\\?$/gi.test(uri); + isUnixUri = /^(\/)?(\/(?![.])[^/]*)*\/?$/gi.test(uri);//folders beginning with . are hidden on Mac / Unix + status = isWindowsUri || isUnixUri; + if(isWindowsUri && isUnixUri){status = false;} + } + return status; + } + }, + //////////////////////////////////////////////////////////////////// /*** * check if the file exists -- cgit v1.2.3