src/preferences/PreferencesDialogs.js
function _validateBaseUrl(url) {
        var result = "";
        // Empty url means "no server mapping; use file directly"
        if (url === "") {
            return result;
        }

        var obj = PathUtils.parseUrl(url);
        if (!obj) {
            result = Strings.BASEURL_ERROR_UNKNOWN_ERROR;
        } else if (obj.href.search(/^(http|https):\/\//i) !== 0) {
            result = StringUtils.format(Strings.BASEURL_ERROR_INVALID_PROTOCOL, obj.href.substring(0, obj.href.indexOf("//")));
        } else if (obj.search !== "") {
            result = StringUtils.format(Strings.BASEURL_ERROR_SEARCH_DISALLOWED, obj.search);
        } else if (obj.hash !== "") {
            result = StringUtils.format(Strings.BASEURL_ERROR_HASH_DISALLOWED, obj.hash);
        } else {
            var index = url.search(/[ \^\[\]\{\}<>\\"\?]+/);
            if (index !== -1) {
                result = StringUtils.format(Strings.BASEURL_ERROR_INVALID_CHAR, url[index]);
            }
        }

        return result;
    }
function _validateBaseUrl(url) {
        var result = "";
        // Empty url means "no server mapping; use file directly"
        if (url === "") {
            return result;
        }

        var obj = PathUtils.parseUrl(url);
        if (!obj) {
            result = Strings.BASEURL_ERROR_UNKNOWN_ERROR;
        } else if (obj.href.search(/^(http|https):\/\//i) !== 0) {
            result = StringUtils.format(Strings.BASEURL_ERROR_INVALID_PROTOCOL, obj.href.substring(0, obj.href.indexOf("//")));
        } else if (obj.search !== "") {
            result = StringUtils.format(Strings.BASEURL_ERROR_SEARCH_DISALLOWED, obj.search);
        } else if (obj.hash !== "") {
            result = StringUtils.format(Strings.BASEURL_ERROR_HASH_DISALLOWED, obj.hash);
        } else {
            var index = url.search(/[ \^\[\]\{\}<>\\"\?]+/);
            if (index !== -1) {
                result = StringUtils.format(Strings.BASEURL_ERROR_INVALID_CHAR, url[index]);
            }
        }

        return result;
    }
function _validateBaseUrl ( url ) { var result = "" ; // Empty url means "no server mapping; use file directly" if ( url === "" ) { return result ; } var obj = PathUtils . parseUrl ( url ) ; if ( ! obj ) { result = Strings . BASEURL_ERROR_UNKNOWN_ERROR ; } else if ( obj . href . search ( / ^(http|https):\/\/ / i ) !== 0 ) { result = StringUtils . format ( Strings . BASEURL_ERROR_INVALID_PROTOCOL , obj . href . substring ( 0 , obj . href . indexOf ( "//" ) ) ) ; } else if ( obj . search !== "" ) { result = StringUtils . format ( Strings . BASEURL_ERROR_SEARCH_DISALLOWED , obj . search ) ; } else if ( obj . hash !== "" ) { result = StringUtils . format ( Strings . BASEURL_ERROR_HASH_DISALLOWED , obj . hash ) ; } else { var index = url . search ( / [ \^\[\]\{\}<>\\"\?]+ / ) ; if ( index !== - 1 ) { result = StringUtils . format ( Strings . BASEURL_ERROR_INVALID_CHAR , url [ index ] ) ; } } return result ; }
Validate that text string is a valid base url which should map to a server folder
@param {string} url
@return {string} Empty string if valid, otherwise error string
Validate that text string is a valid base url which should map to a server folder