Skip to content

Conversation

@batbyR
Copy link

@batbyR batbyR commented Oct 6, 2019

Fixes #9

Ignore request to "localhost" or "127.0.0.1" 🙈

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