Uri.origin should never throw #55997
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
library-core
type-enhancement
A request for a change that isn't a bug
I believe Uri.origin should never throw.
If you disagree with me on these values, then at least Uri.origin should always return null instead of throwing.
Indeed, it is not clear when we use .origin prop on a URI that it can throw which leads to bugs.
My use case : I am writing a password manager, so I have to deal with unknown URIs (such as URIs imported from other tools).
I consider that anything that Uri.tryParse can parse is a valid URI (which seems fair right ?)
I discovered that .origin could throw, which I was of course able to fix by testing properties. But in the future, it is very probable I will forget about this peculiarity and create another bug using .origin an a URI without testing scheme and host first, which is why I filed this issue.
This would be a breaking change. I'm not sure about its impact, but I would say it's easily manageable.
dart version : 3.4.3
The text was updated successfully, but these errors were encountered: