]> git.ktnx.net Git - icedeb.git/blobdiff - chrome/icedeb.js
trim clipbiard contents before using it
[icedeb.git] / chrome / icedeb.js
index df6363f3cfab8cfa1124fd07411783f32eb2349e..3b9eb7bcc1e8ee52f1f4374bc23b7938813fb6ba 100644 (file)
@@ -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;