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

Add strictOrigins option #3

Merged
merged 2 commits into from
Dec 19, 2020
Merged

Add strictOrigins option #3

merged 2 commits into from
Dec 19, 2020

Conversation

fregante
Copy link
Owner

Fixes #1

@fregante fregante added the enhancement New feature or request label Dec 19, 2020
index.ts Outdated
Comment on lines 33 to 43
const hostRegex = /:[/][/]([^/]+)/;
function parseDomain(origin: string): string {
return origin
// Extract host
.split(hostRegex)[1]!

// Discard anything but the first- and second-level domains
.split('.')
.slice(-2)
.join('.');
}
Copy link
Owner Author

@fregante fregante Dec 19, 2020

Choose a reason for hiding this comment

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

This is an extremely ugly way to extract google.com from *://*.google.com/*. Is there a non-awful regex that reliably picks only the A.B part regardless of dot count in the host?

@fregante fregante merged commit 8fb006b into master Dec 19, 2020
@fregante fregante deleted the loose-domain-matching branch December 19, 2020 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Safari support: every host permission is reported as "additional"
1 participant