Change way of getting domain, use more efficient parseuri.js

This commit is contained in:
Grégory Soutadé 2013-10-12 11:16:07 +02:00
parent aad001bb25
commit 93ccb6802b
3 changed files with 36 additions and 2 deletions

View File

@ -1,4 +1,4 @@
gPass : global password
gPass : global Password
=======================
Introduction

View File

@ -25,6 +25,7 @@ var Hashtable = require("jshashtable-3.0").Hashtable;
// http://code.google.com/p/crypto-js/
var sha256 = require("jssha256").sha256;
var aes = require("jsaes").aes;
var parseURI = require("parseuri").parseURI;
var prefSet = require("simple-prefs");
// Global document
var doc;
@ -62,7 +63,8 @@ function on_sumbit()
var fields = form.getElementsByTagName("input");
var my_map = new Hashtable();
domain = form.ownerDocument.domain;
domain = parseURI.parseUri(form.ownerDocument.baseURI);
domain = domain["host"];
// Get all <input type="text">
for (i=0; i<fields.length; i++)

View File

@ -0,0 +1,32 @@
// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// MIT License
exports.parseURI = {
parseUri : function (str) {
var o = {
strictMode: false,
key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
q: {
name: "queryKey",
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
},
parser: {
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
}},
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
uri = {},
i = 14;
while (i--) uri[o.key[i]] = m[i] || "";
uri[o.q.name] = {};
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
if ($1) uri[o.q.name][$1] = $2;
});
return uri;
}
};