Skip to content

Commit

Permalink
Refactored url parsing logic into getFullUrlPath function
Browse files Browse the repository at this point in the history
  • Loading branch information
sahat committed Feb 19, 2016
1 parent 318ebf7 commit 5883aa9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions satellizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,7 @@ if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.ex
var redirectUriParser = document.createElement('a');
redirectUriParser.href = redirectUri;

var redirectUriPath = redirectUriParser.protocol + '//' + redirectUriParser.hostname +
(redirectUriParser.port ? ':' + redirectUriParser.port: '') +
redirectUriParser.pathname;
var redirectUriPath = utils.getFullUrlPath(redirectUriParser);

var polling = $interval(function() {
if (!Popup.popupWindow || Popup.popupWindow.closed || Popup.popupWindow.closed === undefined) {
Expand All @@ -766,9 +764,7 @@ if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.ex
}

try {
var popupWindowPath = Popup.popupWindow.location.protocol + '//' + Popup.popupWindow.location.hostname +
(Popup.popupWindow.location.port ? ':' + Popup.popupWindow.location.port : '') +
Popup.popupWindow.location.pathname;
var popupWindowPath = utils.getFullUrlPath(Popup.popupWindow.location);

// Redirect has occurred.
if (popupWindowPath === redirectUriPath) {
Expand Down Expand Up @@ -831,6 +827,11 @@ if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.ex
return Popup;
}])
.service('SatellizerUtils', function() {
this.getFullUrlPath = function(location) {
return location.protocol + '//' + location.hostname +
(location.port ? ':' + location.port : '') + location.pathname;
};

this.camelCase = function(name) {
return name.replace(/([\:\-\_]+(.))/g, function(_, separator, letter, offset) {
return offset ? letter.toUpperCase() : letter;
Expand Down
Loading

0 comments on commit 5883aa9

Please sign in to comment.