| 120 | | |
| 121 | | emailMatch = href.match( emailRegex ); |
| 122 | | |
| 123 | | if( emailMatch ) |
| 124 | | { |
| 125 | | var subjectMatch = href.match( emailSubjectRegex ), |
| 126 | | bodyMatch = href.match( emailBodyRegex ); |
| 127 | | |
| 128 | | retval.type = 'email'; |
| 129 | | var email = ( retval.email = {} ); |
| 130 | | email.address = emailMatch[ 1 ]; |
| 131 | | subjectMatch && ( email.subject = decodeURIComponent( subjectMatch[ 1 ] ) ); |
| 132 | | bodyMatch && ( email.body = decodeURIComponent( bodyMatch[ 1 ] ) ); |
| 133 | | } |
| 134 | | } |
| 135 | | // Protected email link as function call. |
| 136 | | else if( emailProtection ) |
| 137 | | { |
| 138 | | href.replace( functionCallProtectedEmailLinkRegex, function( match, funcName, funcArgs ) |
| 139 | | { |
| 140 | | if( funcName == compiledProtectionFunction.name ) |
| 141 | | { |
| 142 | | retval.type = 'email'; |
| 143 | | var email = retval.email = {}; |
| | 107 | // Protected email link as function call. |
| | 108 | else if( emailProtection ) |
| | 109 | { |
| | 110 | href.replace( functionCallProtectedEmailLinkRegex, function( match, funcName, funcArgs ) |
| | 111 | { |
| | 112 | if( funcName == compiledProtectionFunction.name ) |
| | 113 | { |
| | 114 | retval.type = 'email'; |
| | 115 | var email = retval.email = {}; |
| 145 | | var paramRegex = /[^,\s]+/g, |
| 146 | | paramQuoteRegex = /(^')|('$)/g, |
| 147 | | paramsMatch = funcArgs.match( paramRegex ), |
| 148 | | paramsMatchLength = paramsMatch.length, |
| 149 | | paramName, |
| 150 | | paramVal; |
| | 117 | var paramRegex = /[^,\s]+/g, |
| | 118 | paramQuoteRegex = /(^')|('$)/g, |
| | 119 | paramsMatch = funcArgs.match( paramRegex ), |
| | 120 | paramsMatchLength = paramsMatch.length, |
| | 121 | paramName, |
| | 122 | paramVal; |
| 152 | | for ( var i = 0; i < paramsMatchLength; i++ ) |
| 153 | | { |
| 154 | | paramVal = decodeURIComponent( unescapeSingleQuote( paramsMatch[ i ].replace( paramQuoteRegex, '' ) ) ); |
| 155 | | paramName = compiledProtectionFunction.params[ i ].toLowerCase(); |
| 156 | | email[ paramName ] = paramVal; |
| 157 | | } |
| 158 | | email.address = [ email.name, email.domain ].join( '@' ); |
| 159 | | } |
| 160 | | } ); |
| 161 | | } |
| 162 | | else |
| 163 | | retval.type = 'url'; |
| | 124 | for ( var i = 0; i < paramsMatchLength; i++ ) |
| | 125 | { |
| | 126 | paramVal = decodeURIComponent( unescapeSingleQuote( paramsMatch[ i ].replace( paramQuoteRegex, '' ) ) ); |
| | 127 | paramName = compiledProtectionFunction.params[ i ].toLowerCase(); |
| | 128 | email[ paramName ] = paramVal; |
| | 129 | } |
| | 130 | email.address = [ email.name, email.domain ].join( '@' ); |
| | 131 | } |
| | 132 | } ); |
| | 133 | } |
| | 134 | } |
| | 135 | |
| | 136 | if( !retval.type ) |
| | 137 | { |
| | 138 | if ( ( anchorMatch = href.match( anchorRegex ) ) ) |
| | 139 | { |
| | 140 | retval.type = 'anchor'; |
| | 141 | retval.anchor = {}; |
| | 142 | retval.anchor.name = retval.anchor.id = anchorMatch[1]; |
| | 143 | } |
| | 144 | // Protected email link as encoded string. |
| | 145 | else if ( emailMatch = href.match( emailRegex ) ) |
| | 146 | { |
| | 147 | var subjectMatch = href.match( emailSubjectRegex ), |
| | 148 | bodyMatch = href.match( emailBodyRegex ); |
| | 149 | |
| | 150 | retval.type = 'email'; |
| | 151 | var email = ( retval.email = {} ); |
| | 152 | email.address = emailMatch[ 1 ]; |
| | 153 | subjectMatch && ( email.subject = decodeURIComponent( subjectMatch[ 1 ] ) ); |
| | 154 | bodyMatch && ( email.body = decodeURIComponent( bodyMatch[ 1 ] ) ); |
| | 155 | } |
| | 156 | // urlRegex matches empty strings, so need to check for href as well. |
| | 157 | else if ( href && ( urlMatch = href.match( urlRegex ) ) ) |
| | 158 | { |
| | 159 | retval.type = 'url'; |
| | 160 | retval.url = {}; |
| | 161 | retval.url.protocol = urlMatch[1]; |
| | 162 | retval.url.url = urlMatch[2]; |
| | 163 | } |
| | 164 | else |
| | 165 | retval.type = 'url'; |
| | 166 | } |