-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_url.js
More file actions
18 lines (18 loc) · 745 Bytes
/
_url.js
File metadata and controls
18 lines (18 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var _url = {
root: window.location.protocol + '//' + window.location.hostname + window.location.pathname,
host: window.location.hostname,
href: function(url, withTitle){
if(url===undefined) return document.location.href;
if(url=="/") url = "";
if(withTitle!==null&&withTitle) document.title = this.domain.substring(0, 1) + '/' + url; // ⚛
try{ if(window.history) history.pushState("data", "", this.root + url); }catch(e){}
},
GET: function(name, url){
if(url===undefined) url = document.location.href;
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(url);
return results === null ? null : results[1];
}
};