Skip to content

Fix: prevent malformed URL error when parsing IP:PORT by adding defau… #847

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

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

Conversation

surelyruchi
Copy link

PR Description

This PR fixes an issue where URLs containing IP addresses with ports (e.g., 8.8.8.8:443) were being treated as malformed due to the absence of a URI scheme (http://, https://, etc.).

Related Issues

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I am using the latest Flutter stable branch (run flutter upgrade and verify)
  • I have run the tests (flutter test) and all tests are passing

Added/updated tests?

We encourage you to add relevant test cases.

  • Yes
  • No, and this is why: This is a small, focused fix , tests will be added later if required based on usage or feedback.

OS on which you have developed and tested the feature?

  • Windows
  • macOS
  • Linux

@surelyruchi
Copy link
Author

Hey @ashitaprasad @animator, this is a minor change in the code. Could you take a quick look and share your thoughts when you get a chance?

Basically, the issue was URL's like 8.8.8.8:443 without scheme passing through Uri.parse(url) treats it as a string and returns null value which resulted to malformed url and previously default scheme were getting added if the URL matched kLocalhostRegex which only handled localhost.
So I added a generic regex check to add missing URL scheme if missing from such address.

@animator
Copy link
Member

Sure. We will review the code.

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.

URL with IP:PORT returns malformed URL error
2 participants