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

Add parsing without raising exceptions #149

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

Conversation

TobiasBales
Copy link

@TobiasBales TobiasBales commented Jan 23, 2025

Similar to what Integer(value, exception: false) does but for
URI.parse(value, exception: false).

The change is implemented for the default parser (RFC3986) and also RFC2396.
The goal is to allow parsing invalid/user input without having to have control flow via exceptions or by having to wrap URI.parse in a method per project.

This change can be tried via~/.rubies/ruby-master/bin/ruby -r 'uri' -e 'URI.parse("https://example.com/\[\]", exception: false)' and ~/.rubies/ruby-master/bin/ruby -r 'uri' -e 'URI.parse("https://example.com/\[\]")' respectively (or withexception: true) and is also covered by tests.

Or by just changing the tests to observe the behavior

Similar to what Integer(value, exception: false) does but for
URI.parse(value, exception: false).

The change is implemented for the default parser (RFC3986) and also
RFC2396.
The goal is to allow parsing invalid/user input without having to have
control flow via exceptions or by having to wrap URI.parse in a method
per project.

This change can be tried via`~/.rubies/ruby-master/bin/ruby -r 'uri' -e
'URI.parse("https://example.com/\[\]", exception: false)'` and
`~/.rubies/ruby-master/bin/ruby -r 'uri' -e
'URI.parse("https://example.com/\[\]")'` respectively (or
with`exception: true`) and is also covered by tests.
Or by just changing the tests to observe the behavior
@TobiasBales
Copy link
Author

@nobu any chance you could approve the workflow run when you have some time?
Would be most appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant