[480] | 1 | define([ |
---|
| 2 | ], function() { |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | // parseUri 1.2.2 |
---|
| 6 | // (c) Steven Levithan <stevenlevithan.com> |
---|
| 7 | // MIT License |
---|
| 8 | |
---|
| 9 | function parseUri (str) { |
---|
| 10 | var o = parseUri.options, |
---|
| 11 | m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), |
---|
| 12 | uri = {}, |
---|
| 13 | i = 14; |
---|
| 14 | |
---|
| 15 | while (i--) uri[o.key[i]] = m[i] || ""; |
---|
| 16 | |
---|
| 17 | uri[o.q.name] = {}; |
---|
| 18 | uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { |
---|
| 19 | if ($1) uri[o.q.name][$1] = $2; |
---|
| 20 | }); |
---|
| 21 | |
---|
| 22 | return uri; |
---|
| 23 | }; |
---|
| 24 | |
---|
| 25 | parseUri.options = { |
---|
| 26 | strictMode: false, |
---|
| 27 | key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], |
---|
| 28 | q: { |
---|
| 29 | name: "queryKey", |
---|
| 30 | parser: /(?:^|&)([^&=]*)=?([^&]*)/g |
---|
| 31 | }, |
---|
| 32 | parser: { |
---|
| 33 | strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, |
---|
| 34 | loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ |
---|
| 35 | } |
---|
| 36 | }; |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | // |
---|
| 40 | function xmlToString(data) { |
---|
| 41 | //data.xml check for IE |
---|
| 42 | var xmlstr = data.xml ? data.xml : (new XMLSerializer()).serializeToString(data); |
---|
| 43 | return xmlstr; |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | function equalsString(a, b) { |
---|
| 47 | if (!a) { |
---|
| 48 | return false; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | if (!b) { |
---|
| 52 | return false; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | return jQuery.trim(a).localeCompare(jQuery.trim(b)) == 0; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | function encodeXML(str) { |
---|
| 59 | return str.replace(/&/g, '&') |
---|
| 60 | .replace(/</g, '<') |
---|
| 61 | .replace(/>/g, '>') |
---|
| 62 | .replace(/"/g, '"') |
---|
| 63 | .replace(/'/g, '''); |
---|
| 64 | }; |
---|
| 65 | |
---|
| 66 | return { |
---|
| 67 | parseUri: parseUri, |
---|
| 68 | xmlToString: xmlToString, |
---|
| 69 | equalsString: equalsString, |
---|
| 70 | encodeXML: encodeXML, |
---|
| 71 | }; |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | }); |
---|