aboutsummaryrefslogtreecommitdiff
path: root/chrome/content/common.js
diff options
context:
space:
mode:
authorEinar Egilsson2007-05-21 22:03:05 +0000
committerEinar Egilsson2007-05-21 22:03:05 +0000
commit502c24f18cdfa0f808d9383313bb4f965c7fb11f (patch)
treec9f2523995b6fc59e3bf6cc3bcc9200bbedd5e95 /chrome/content/common.js
Redirector
git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@53 119bf307-c92d-0410-89bd-8f53e6181181
Diffstat (limited to 'chrome/content/common.js')
-rw-r--r--chrome/content/common.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/chrome/content/common.js b/chrome/content/common.js
new file mode 100644
index 0000000..7d13e4b
--- /dev/null
+++ b/chrome/content/common.js
@@ -0,0 +1,37 @@
+
+
+var RedirectorCommon = {
+
+ wildcardMatch : function(pattern, text) {
+ var parts
+ , part
+ , i
+ , pos;
+
+ parts = pattern.split('*');
+
+ for (i in parts) {
+
+ part = parts[i];
+
+ pos = text.indexOf(part);
+
+ if (pos == -1) {
+ return false;
+ }
+
+ if (i == 0 && pos != 0) {
+ return false;
+ }
+
+ if (i == parts.length -1 && i != "" && text.substr(text.length - part.length) != part) {
+ return false;
+
+ }
+
+ text = text.substr(pos + part.length);
+ }
+
+ return true;
+ }
+}; \ No newline at end of file