diff options
Diffstat (limited to 'chrome/content/redirect.js')
-rw-r--r-- | chrome/content/redirect.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/chrome/content/redirect.js b/chrome/content/redirect.js index 08af778..be6cb96 100644 --- a/chrome/content/redirect.js +++ b/chrome/content/redirect.js @@ -8,9 +8,10 @@ var Redirect = { $('txtExampleUrl').value = item.exampleUrl; $('txtPattern').value = item.pattern; $('txtRedirectUrl').value = item.redirectUrl || ''; + $('txtExcludePattern').value = item.excludePattern || ''; $('chkOnlyIfLinkExists').checked = item.onlyIfLinkExists || false; - $('txtPattern').focus(); + $('txtPattern').focus(); this.strings = document.getElementById("redirector-strings"); if (item.patternType == kRedirectorRegex) { @@ -30,6 +31,7 @@ var Redirect = { } item.exampleUrl =$('txtExampleUrl').value; item.redirectUrl = $('txtRedirectUrl').value; + item.excludePattern = $('txtExcludePattern').value; item.onlyIfLinkExists = $('chkOnlyIfLinkExists').checked; item.saved = true; @@ -37,22 +39,32 @@ var Redirect = { }, testPattern : function() { - var redirectUrl, pattern, example, extName; + var redirectUrl, pattern, excludePattern, example, extName, isExcluded; redirectUrl = $('txtRedirectUrl').value; pattern = $('txtPattern').value; + excludePattern = $('txtExcludePattern').value; example = $('txtExampleUrl').value; extName = this.strings.getString('extensionName'); if ($('rdoRegex').selected) { redirectUrl = Redirector.regexMatch(pattern, example, redirectUrl); + if (excludePattern) { + isExcluded = Redirector.regexMatch(excludePattern, example, 'exclude'); + } } else { redirectUrl = Redirector.wildcardMatch(pattern, example, redirectUrl); + if (excludePattern) { + isExcluded = Redirector.wildcardMatch(excludePattern, example, 'exclude'); + } } - if (redirectUrl || (redirectUrl === '' && $('txtRedirectUrl').value === '')) { + var isRedirectMatch = redirectUrl || (redirectUrl === '' && $('txtRedirectUrl').value === ''); + if (isRedirectMatch && !isExcluded) { RedirLib.msgBox(extName, this.strings.getFormattedString('testPatternSuccess', [pattern, example, redirectUrl])); + } else if (isExcluded) { + RedirLib.msgBox(extName, this.strings.getFormattedString('testPatternExclude', [example, excludePattern])); } else { RedirLib.msgBox(extName, this.strings.getFormattedString('testPatternFailure', [pattern, example])); } |