Skip to content

Commit f454c3c

Browse files
committed
Require window.location to get values from request
1 parent 6508e37 commit f454c3c

File tree

6 files changed

+32
-6
lines changed

6 files changed

+32
-6
lines changed

dist/jpack.bundled.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jpack.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

es/request/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const request = {
1717
* @returns {boolean}
1818
*/
1919
isHttps: function(){
20+
this.requireWindowLocation();
2021
return window.location.protocol === 'https:';
2122
},
2223

@@ -28,6 +29,7 @@ export const request = {
2829
* @returns {string}
2930
*/
3031
getDomain: function(){
32+
this.requireWindowLocation();
3133
return window.location.hostname || window.location.host;
3234
},
3335

@@ -39,6 +41,7 @@ export const request = {
3941
* @returns {string}
4042
*/
4143
getDomainWithProtocol: function(){
44+
this.requireWindowLocation();
4245
return window.location.origin;
4346
},
4447

@@ -50,6 +53,7 @@ export const request = {
5053
* @returns {string}
5154
*/
5255
getURI: function(){
56+
this.requireWindowLocation();
5357
return window.location.pathname;
5458
},
5559

@@ -61,6 +65,7 @@ export const request = {
6165
* @returns {string}
6266
*/
6367
getURIWithQueryString: function(){
68+
this.requireWindowLocation();
6469
return window.location.pathname + window.location.search;
6570
},
6671

@@ -72,6 +77,7 @@ export const request = {
7277
* @returns {string}
7378
*/
7479
getFullURL: function(){
80+
this.requireWindowLocation();
7581
return window.location.href;
7682
},
7783

@@ -87,4 +93,11 @@ export const request = {
8793
appendSlash: function(url = ''){
8894
return url[url.length-1] !== '/' ? url+'/' : url;
8995
},
96+
97+
/**
98+
* Check for required window.location
99+
*/
100+
requireWindowLocation: function(){
101+
if( typeof window.location === "undefined" || !window.location ) throw `Window.Location is required for jpack.request`;
102+
},
90103
};

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@htmlguyllc/jpack",
3-
"version": "9.0.24",
3+
"version": "9.0.25",
44
"description": "Core Javascript Library of Everyday Objects, Events, and Utilities",
55
"keywords": [
66
"javascript",

test/_jpack.bundled.js

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)