Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow absolute URLs in ShopifyApp::LoginProtection.redirection_javascript #389

Merged
merged 1 commit into from
Feb 27, 2017

Conversation

Hammadk
Copy link
Member

@Hammadk Hammadk commented Feb 22, 2017

The current ShopifyApp::LoginProtection.redirection_javascript only allows you to pass in a relative URL (/login). This is because we always set the location in #postMessage to:

data: { location: window.location.origin + #{url.to_json} }

Instead, we need to allow absolute URLs as well (https//SHOP.myshopify.com/admin/charges). We create a normalized link to do this:

normalizedLink = document.createElement('a');
normalizedLink.href = #{url.to_json};
data: { location: normalizedLink.href }

Tested in the following browsers:

  • Canary Chrome 58
  • Firefox 43.0.4
  • Safari 10.0.3
  • Chrome 56
  • IE11 on Windows 7

Fixes #387

@Hammadk Hammadk changed the title WIP ~ Allow absolute URLs in ShopifyApp::LoginProtection.redirection_javascript Allow absolute URLs in ShopifyApp::LoginProtection.redirection_javascript Feb 26, 2017
Copy link

@gavinsmith gavinsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to me 👍

@Hammadk Hammadk merged commit e435d9e into master Feb 27, 2017
@Hammadk Hammadk deleted the support-absolute-urls branch February 27, 2017 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants