From: Damyan Ivanov Date: Fri, 6 Mar 2009 07:07:03 +0000 (+0200) Subject: trim clipbiard contents before using it X-Git-Tag: 0.7 X-Git-Url: https://git.ktnx.net/?p=icedeb.git;a=commitdiff_plain;h=refs%2Ftags%2F0.7 trim clipbiard contents before using it removes leading/trailing spaces, leading # and trailing /:-, that helps when selecting using double-click --- 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;