From 88a382a54500d6572446b453a560ef072128a393 Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Mon, 26 Oct 2009 08:13:15 +0000 Subject: Ready for final test git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@288 119bf307-c92d-0410-89bd-8f53e6181181 --- chrome/content/code/editRedirect.xul.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'chrome/content') diff --git a/chrome/content/code/editRedirect.xul.js b/chrome/content/code/editRedirect.xul.js index 72513e8..0902645 100644 --- a/chrome/content/code/editRedirect.xul.js +++ b/chrome/content/code/editRedirect.xul.js @@ -34,6 +34,7 @@ var EditRedirect = { onAccept : function() { var args = window.arguments[0]; + var msg, title; args.saved = true; this.saveValues(args.redirect); @@ -42,12 +43,25 @@ var EditRedirect = { if (!/^\s*$/.test(args.redirect.exampleUrl)) { var result = args.redirect.getMatch(args.redirect.exampleUrl); if (!result.isMatch) { - //TODO: warn about match + title = this.strings.getString('warningExampleUrlDoesntMatchPatternTitle'); + msg = this.strings.getString('warningExampleUrlDoesntMatchPattern'); + var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); + var rv = ps.confirmEx(window, title, msg, ps.STD_YES_NO_BUTTONS, ps.BUTTON_TITLE_YES, ps.BUTTON_TITLE_NO, null, null, {}); + return rv == 0; } else { - var resultUrl = ''; + var resultUrl = result.redirectTo; + if (!resultUrl.match(/https?:/)) { + var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService); + var uri = ioService.newURI(args.redirect.exampleUrl, null, null); + resultUrl = uri.resolve(resultUrl); + } + var secondResult = args.redirect.getMatch(resultUrl); if (secondResult.isMatch) { - //TODO: Warn about recursive match... + title = this.strings.getString('errorExampleUrlMatchesRecursiveTitle'); + msg = this.strings.getFormattedString('errorExampleUrlMatchesRecursive', [args.redirect.exampleUrl, resultUrl]); + this.msgBox(title, msg); + return false; } } } -- cgit v1.2.3-70-g09d2