-
Notifications
You must be signed in to change notification settings - Fork 4
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
Check only hostname for URL sources #191
Conversation
This fix relies on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this issue. The tests look good, and I can’t think of any other edge cases that would pose a problem here.
const sourceURL = new URL(source); | ||
source = sourceURL.hostname; | ||
} catch (e) { | ||
// Source string is not a url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this fallthrough will preserve the original passed-in value of source
. 👍
You have a point that the rule will only catch either problematic URLs in isolation or phrases that aren’t URLs, but not URLs embedded in other text. I suspect this will be unlikely for the particular sources we’re flagging. The goal is to head off inadvertent mistakes or casual, well-meaning usage of problematic sources, but there are plenty of ways to intentionally get around the warning, such as not entering a source at all. |
For future reference: you’ll generally want to avoid posting a pull request from a branch with the same name as the target branch. In this case, you’d want to create a new branch specific to the bug fix. PRing staging into staging will give you a harder time keeping the branch up-to-date as this upstream repository changes. Once this PR lands, you can delete your branch and fetch it again. |
This PR aims to solve OpenHistoricalMap/issues#643
It uses the
URL()
constructor to check if the source is a URL and only uses the hostname on the regex checks.New tests were also added to cover having a URL in the source string.