aboutsummaryrefslogtreecommitdiff
path: root/chrome
diff options
context:
space:
mode:
authorEinar Egilsson2008-01-23 22:22:35 +0000
committerEinar Egilsson2008-01-23 22:22:35 +0000
commitbcbcd61eb9fc91a9ed1b3096ce9f2b686a2114b9 (patch)
tree3d79e540332aa12ae71e94c150c71fd7f890f8ff /chrome
parentabc92ba06bb84d544a0d1deb065eb608cac8190e (diff)
Version 1.5.1
git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@104 119bf307-c92d-0410-89bd-8f53e6181181
Diffstat (limited to 'chrome')
-rw-r--r--chrome/content/help.html10
-rw-r--r--chrome/content/redirector.js32
-rw-r--r--chrome/locale/en-US/redirector.properties3
3 files changed, 10 insertions, 35 deletions
diff --git a/chrome/content/help.html b/chrome/content/help.html
index b4846aa..e74048e 100644
--- a/chrome/content/help.html
+++ b/chrome/content/help.html
@@ -23,7 +23,6 @@
</li>
<li><a href="#wildcards">Wildcards</a></li>
<li><a href="#regularexpressions">Regular expressions</a></li>
- <li><a href="#xpathredirects">XPath redirects</a></li>
<li><a href="#examples">Examples</a>
<ol>
<li><a href="#ex1">Static redirect</a></li>
@@ -71,8 +70,7 @@
include pattern. You can use the special signs $1, $2, $3 etc. in the url, they will be replaced by the results of captures with regular
expressions or stars with wildcards. For instance, if you have the include pattern <em>http://google.com/*</em>, redirect to <em>http://froogle.com/$1</em>
and you open the page http://google.com/foobar, then you will be redireced to http://froogle.com/foobar, since 'foobar' was what the star replaced. $1 is for the
- first star in the pattern, $2 for the second and so on. For regular expression $1 is for the first parantheses, $2 for the second etc. The redirect url
- can also be specified as a <a href="#xpathredirects">XPath expression</a>.</li>
+ first star in the pattern, $2 for the second and so on. For regular expression $1 is for the first parantheses, $2 for the second etc.</li>
<li><a name="patterntype"></a><strong>Pattern type:</strong> This specifies how Redirector should interpret the patterns, either as
<a href="#wildcards">wildcards</a> or <a href="#regularexpressions#">regular expressions</a>.</li>
@@ -115,12 +113,6 @@
the ? sign in the querystring of the url. ? is a special character in regular expressions so if you want to match an url with a querystring
you should escape it as \?).</p>
- <a name="xpathredirects"></a>
- <h4>XPath redirects</h4>
- <p>The redirect url can be specified as an xpath expression by starting it with xpath: and then you will be redirected to the url
- that the xpath expression matches. Example: Redirect url is xpath:/div/span/a/@href, then you will be redirected to the href value
- of the first link that's inside a div in the original page.</p>
-
<a name="examples"></a>
<h4>Examples</h4>
diff --git a/chrome/content/redirector.js b/chrome/content/redirector.js
index 62966d6..98d1c4b 100644
--- a/chrome/content/redirector.js
+++ b/chrome/content/redirector.js
@@ -67,11 +67,11 @@ var Redirector = {
//we need the original page to verify that it exists.
//Slow redirect will be done automatically.
if (redirectUrl) {
- if (!redirect.onlyIfLinkExists && !redirect.redirectUrl.startsWith('xpath:')) {
- RedirLib.debug('%1 matches %2, and it\'s not only if link exists and not an xpath expression. Can do instant redirect.'._(redirect.pattern, url));
+ if (redirect.redirectUrl.startsWith('xpath:')) {
+ RedirLib.msgBox(this.strings.getString('extensionName'), this.strings.getString('xpathDeprecated'));
+ } else if (!redirect.onlyIfLinkExists) {
+ RedirLib.debug('%1 matches %2, and it\'s not only if link exists. Can do instant redirect.'._(redirect.pattern, url));
return { 'url' : redirectUrl, 'pattern' : redirect.pattern};
- } else if (redirect.redirectUrl.startsWith('xpath:')) {
- RedirLib.debug('%1 matches %2, but the redirect is a xpath expression and so has to be a slow redirect'._(redirect.pattern, url));
} else {
RedirLib.debug('%1 matches %2, but it\'s "only if link exists" and so has to be a slow redirect'._(redirect.pattern, url));
}
@@ -148,29 +148,11 @@ var Redirector = {
goto : function(redirectUrl, pattern, url, doc) {
-
- if (redirectUrl.startsWith('xpath:')) {
-
- var xpath = redirectUrl.substr('xpath:'.length);
- RedirLib.debug('Evaluating xpath: ' + xpath);
- xpathResult = doc.evaluate(redirectUrl.substr('xpath:'.length), doc, null, XPathResult.STRING_TYPE,null);
- if (!xpathResult) {
- //fail silently
- RedirLib.debug('%1 returned nothing on url %2'._(xpath, url));
- return;
- } else {
- RedirLib.debug('%1 evaluated to %2'._(redirectUrl, xpathResult.stringValue));
- redirectUrl = xpathResult.stringValue;
- if (redirectUrl == '') {
- RedirLib.debug('XPath failed, no redirection will be made');
- return;
- }
- }
- }
-
redirectUrl = this.makeAbsoluteUrl(url, redirectUrl);
- if (redirectUrl == url) {
+ if (redirectUrl.startsWith('xpath:')) {
+ //Do nothing, the instant redirect will have popped up a message
+ } else if (redirectUrl == url) {
RedirLib.msgBox(this.strings.getString('extensionName'), this.strings.getFormattedString('recursiveError', [pattern, redirectUrl]));
} else {
doc.location.href = redirectUrl;
diff --git a/chrome/locale/en-US/redirector.properties b/chrome/locale/en-US/redirector.properties
index f32005d..45207a1 100644
--- a/chrome/locale/en-US/redirector.properties
+++ b/chrome/locale/en-US/redirector.properties
@@ -9,4 +9,5 @@ disabledTooltip=Redirector is disabled
testPatternSuccess=The pattern %S matches example URL %S, and would redirect you to url: %S
testPatternFailure=The pattern %S does not match example URL %S
testPatternExclude=Example URL %S matches the exclude pattern %S and so would not be redirected
-regexPatternError=The pattern '%S' is not a legal regular expression pattern. Details: %S \ No newline at end of file
+regexPatternError=The pattern '%S' is not a legal regular expression pattern. Details: %S
+xpathDeprecated=XPath patterns are no longer supported as of version 1.5.1, please remove those redirects. \ No newline at end of file