aboutsummaryrefslogtreecommitdiff
path: root/chrome/content/common.js
blob: 7d13e4bc024d67ea2fd0e3e43c5c5b4ed6bf37ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;
    }
};