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

Ignore requests to localhost #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

batbyR
Copy link

@batbyR batbyR commented Oct 6, 2019

Fixes #9

Ignore request to "localhost" or "127.0.0.1" 🙈

@@ -9,6 +9,8 @@ extractHostname = (url) => {
return hostname;
}

isFromLocalMachine = (origin) => (origin === "localhost" || origin === "127.0.0.1");
Copy link

Choose a reason for hiding this comment

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

I think it will match more cases using a regexp like:
origin.match(/localhost|[0-9]{2,3}\.[0-9]{2,3}\.[0-9]{2,3}\.[0-9]{2,3}|::1|\.local|^$/gi)

Choose a reason for hiding this comment

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

@cedk This regex don't even match 127.0.0.1. According to this article on IP classes I don't know if a regex would be powerful enough to determine a private IP address (and what about private networks extended on multiple places ?) Maybe an allow-list would better fit ?

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.

Ignore data from localhost
3 participants