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

fix(transport-chrome): allow http for localhost #1580

Merged
merged 5 commits into from
Jul 30, 2024

Conversation

VanishMax
Copy link
Contributor

@VanishMax VanishMax requested review from turbocrime and a team July 29, 2024 11:50
@VanishMax VanishMax self-assigned this Jul 29, 2024
Copy link

changeset-bot bot commented Jul 29, 2024

🦋 Changeset detected

Latest commit: 68c389e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@penumbra-zone/transport-chrome Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines 102 to 107
const fromPageHttps =
!sender.frameId &&
sender.tab?.id &&
(sender.origin.startsWith('https://') ||
sender.origin.startsWith('http://localhost:') ||
sender.origin === 'http://localhost');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Think local host should be broken out. I find this easier to read:

const fromThisExtension = sender.id === chrome.runtime.id;
const fromPageHttps = !sender.frameId && sender.tab?.id && sender.origin.startsWith('https://');
const isLocalhost =
      sender.origin.startsWith('http://localhost:') || sender.origin === 'http://localhost';
const validOrigin = isLocalhost || fromPageHttps || fromThisExtension;
if (!validOrigin) {
  return;
}

@VanishMax VanishMax requested a review from grod220 July 30, 2024 20:24
@VanishMax VanishMax merged commit 06aa65d into main Jul 30, 2024
6 checks passed
@VanishMax VanishMax deleted the fix/allow-http-localhost branch July 30, 2024 20:42
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.

2 participants