nl_tokens: URI // FUNCTION : uri ( value ) Validates if a value is a URI .
pl_tokens: function uri ( val ) { var parts , scheme , authority , path ; if ( ! isString ( val ) ) { return false ; } // [1] Check for illegal characters: if ( ILLEGALS . test ( val ) ) { return false ; } // [2] Check for incomplete HEX escapes: if ( HEX1 . test ( val ) || HEX2 . test ( val ) ) { return false ; } // [3] Split the string into various URI components: parts = val . match ( URI ) ; scheme = <mask> [ 1 ] ; authority = parts [ 2 ] ; path = parts [ 3 ] ; // [4] Scheme is required and must be valid: if ( ! scheme || ! scheme . length || ! SCHEME . test ( scheme . toLowerCase ( ) ) ) { return false ; } // [5] If authority is not present, path must not begin with a '//': if ( ! authority && PATH . test ( path ) ) { return false ; } return true ; }