Skip to content

Commit

Permalink
Require window.location to get values from request
Browse files Browse the repository at this point in the history
  • Loading branch information
HTMLGuyLLC committed Jul 18, 2019
1 parent 6508e37 commit f454c3c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dist/jpack.bundled.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jpack.min.js

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions es/request/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const request = {
* @returns {boolean}
*/
isHttps: function(){
this.requireWindowLocation();
return window.location.protocol === 'https:';
},

Expand All @@ -28,6 +29,7 @@ export const request = {
* @returns {string}
*/
getDomain: function(){
this.requireWindowLocation();
return window.location.hostname || window.location.host;
},

Expand All @@ -39,6 +41,7 @@ export const request = {
* @returns {string}
*/
getDomainWithProtocol: function(){
this.requireWindowLocation();
return window.location.origin;
},

Expand All @@ -50,6 +53,7 @@ export const request = {
* @returns {string}
*/
getURI: function(){
this.requireWindowLocation();
return window.location.pathname;
},

Expand All @@ -61,6 +65,7 @@ export const request = {
* @returns {string}
*/
getURIWithQueryString: function(){
this.requireWindowLocation();
return window.location.pathname + window.location.search;
},

Expand All @@ -72,6 +77,7 @@ export const request = {
* @returns {string}
*/
getFullURL: function(){
this.requireWindowLocation();
return window.location.href;
},

Expand All @@ -87,4 +93,11 @@ export const request = {
appendSlash: function(url = ''){
return url[url.length-1] !== '/' ? url+'/' : url;
},

/**
* Check for required window.location
*/
requireWindowLocation: function(){
if( typeof window.location === "undefined" || !window.location ) throw `Window.Location is required for jpack.request`;
},
};
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@htmlguyllc/jpack",
"version": "9.0.24",
"version": "9.0.25",
"description": "Core Javascript Library of Everyday Objects, Events, and Utilities",
"keywords": [
"javascript",
Expand Down
15 changes: 14 additions & 1 deletion test/_jpack.bundled.js

Large diffs are not rendered by default.

0 comments on commit f454c3c

Please sign in to comment.