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(isURL): allow URLs with colon and no port #1751

Merged

Conversation

MatteoPierro
Copy link
Contributor

@MatteoPierro MatteoPierro commented Oct 3, 2021

fix(isURL): allow URLs with column and no port

This solves the issue #1584

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)

@codecov
Copy link

codecov bot commented Oct 3, 2021

Codecov Report

Merging #1751 (4c4c06b) into master (4ec30b7) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1751   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          102       102           
  Lines         2029      2029           
  Branches       457       457           
=========================================
  Hits          2029      2029           
Impacted Files Coverage Δ
src/lib/isURL.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ec30b7...4c4c06b. Read the comment docs.

@MatteoPierro MatteoPierro changed the title allow url with column and no port fix(isURL): allow URLs with column and no port Oct 3, 2021
@MatteoPierro
Copy link
Contributor Author

Hi @tux-tn Can I have your feedback about this? 🙏

Copy link
Member

@tux-tn tux-tn left a comment

Choose a reason for hiding this comment

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

Hello @MatteoPierro and thank you for your PR!

Is an URL with a colon and no port allowed in IETF standards? if yes can you provide a source?

According to the two RFCs concerning URLs and URls,http://example.com: shouldn't be valid

RFC 3986 ( Uniform Resource Identifier (URI): Generic Syntax)

URI producers and normalizers should omit the port component and its ":" delimiter if port is empty or if its value would be the same as that of the scheme's default

RFC 1738 ( Uniform Resource Locators (URL))

port
The port number to connect to. Most schemes designate protocols that have a default port number. Another port number may optionally be supplied, in decimal, separated from the host by a colon. If the port is omitted, the colon is as well.

@tux-tn tux-tn added needs-more-review 🎉 first-pr blocked For PRs that are blocked due to pending discussions, etc. 🍿 discussion labels Oct 5, 2021
@MatteoPierro
Copy link
Contributor Author

MatteoPierro commented Oct 6, 2021

Hi @tux-tn

If I understand correctly RFC 2396 revises and replaces the RFC 1738.

The URL port is now digit instead of 1digit, since systems are
expected to handle the case where the ":" separator between host and
port is supplied without a port.

About the RFC 3986. I understand that defines only the behavior of producers and normalizers. It's not about the validity of URIs.

URI producers and
normalizers should omit the port component and its ":" delimiter if
port is empty or if its value would be the same as that of the
scheme's default.

So http://example:/ and http://example:80/ are valid URIs but producers and normalizers should just "produce" http://example.

Copy link
Member

@tux-tn tux-tn left a comment

Choose a reason for hiding this comment

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

If I understand correctly RFC 2396 revises and replaces the RFC 1738.

In deed, you are correct. I missed RFC 2396 and allowing colon without port should be a valid behaviour.

Approving your PR! Thank you for your work and for addressing my comment 🎉

@tux-tn tux-tn added ready-to-land For PRs that are reviewed and ready to be landed and removed blocked For PRs that are blocked due to pending discussions, etc. 🍿 discussion needs-more-review labels Oct 6, 2021
@MatteoPierro
Copy link
Contributor Author

Great 🎉 Since it's my first contribution to this project, do I need something else for having this merged?

@tux-tn
Copy link
Member

tux-tn commented Oct 6, 2021

Great 🎉 Since it's my first contribution to this project, do I need something else for having this merged?

No, you just need to wait for @profnandaa to do another review if needed and merge it if everything is okay.

BTW, forgot to ask but did you pick the issue for hacktoberfest?

@MatteoPierro
Copy link
Contributor Author

Yes, for the hacktoberfest 😅

@tux-tn
Copy link
Member

tux-tn commented Oct 6, 2021

@MatteoPierro thank you, added the hacktoberfest label !

Copy link
Member

@profnandaa profnandaa left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your contrib!

@profnandaa profnandaa merged commit 60dffb9 into validatorjs:master Oct 30, 2021
theteladras pushed a commit to theteladras/validator.js that referenced this pull request Oct 30, 2021
@profnandaa profnandaa changed the title fix(isURL): allow URLs with column and no port fix(isURL): allow URLs with colon and no port Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 first-pr hacktoberfest-accepted ready-to-land For PRs that are reviewed and ready to be landed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants