From fa5f4ea596aca3e15b89eb04974b552cc32571ae Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 13 Nov 2014 10:36:47 -0600 Subject: [PATCH] Fixes #391 - trim wysiwyg:// from URL field if it's there. --- webcompat/static/js/lib/bugform.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/webcompat/static/js/lib/bugform.js b/webcompat/static/js/lib/bugform.js index ca88e0668..e5e2b3c6a 100644 --- a/webcompat/static/js/lib/bugform.js +++ b/webcompat/static/js/lib/bugform.js @@ -36,11 +36,23 @@ function BugForm() { } var urlParam = location.search.match(/url=(.+)/); if (urlParam != null) { - urlField.val(decodeURIComponent(urlParam[1])); + // weird Gecko bug. See https://bugzilla.mozilla.org/show_bug.cgi?id=1098037 + urlParam = self.trimWysiwyg(urlParam[1]); + urlField.val(decodeURIComponent(urlParam)); self.copyURL(); self.makeValid('url'); } }, + trimWysiwyg: function(url) { + console.log(url); + //trim wysiwyg://N/ from URL. + var wysiwygRe = /(wysiwyg:\/\/\d+\/)/i; + if (url.search(wysiwygRe) !== 0) { + return url; + } else { + return url.replace(wysiwygRe, ''); + } + }, disableSubmits: function() { submitButtons.prop('disabled', true); submitButtons.addClass('is-disabled');