From 8f5e38a99516512c8cca0855b7b3f68fea0c1aba Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 6 Mar 2009 09:07:03 +0200 Subject: [PATCH] trim clipbiard contents before using it removes leading/trailing spaces, leading # and trailing /:-, that helps when selecting using double-click --- chrome/icedeb.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/chrome/icedeb.js b/chrome/icedeb.js index df6363f..3b9eb7b 100644 --- a/chrome/icedeb.js +++ b/chrome/icedeb.js @@ -26,10 +26,25 @@ function getClipboardText() { return text; } +function trim_keyword(word) { + if (!word) return word; + + var oldword; + do { + oldword = word; + + word = word.replace(/^\s+/, ''); + word = word.replace(/\s+$/, ''); + word = word.replace(/^#/, ''); + word = word.replace(/[-:\/,]$/, ''); + } while ( oldword != word ); + + return word; +} + function lookup_bts(in_new) { - var bug = getClipboardText(); + var bug = trim_keyword(getClipboardText()); if (!bug) return null; - bug = bug.replace(/^#/, ''); var uri="http://bugs.debian.org/" + bug; if (in_new) { @@ -43,7 +58,7 @@ function lookup_bts(in_new) { } function lookup_pts(in_new) { - var pkg = getClipboardText(); + var pkg = trim_keyword(getClipboardText()); if (!pkg) return null; var uri="http://packages.qa.debian.org/" + pkg; @@ -58,7 +73,7 @@ function lookup_pts(in_new) { } function lookup_deb(in_new) { - var pkg = getClipboardText(); + var pkg = trim_keyword(getClipboardText()); if (!pkg) return null; var uri="http://packages.debian.org/" + pkg; -- 2.39.2