-
Notifications
You must be signed in to change notification settings - Fork 72
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
Test cases from #11 for reference implementation #40
Conversation
(note that the test results being asserted here are the ones that make the tests pass, not what the expectations should necessarily be) |
I've added a second commit here that adds some basic validations. I guess the first question is as mentioned in #11 if validations should be performed early (during parsing) or at resolution time as resolution errors. No stress at all if this implementation is entirely undesired - just trying to move conversations forward on this. |
Splitting this up into two commits was really helpful; thanks for doing that. I do think validations should be performed during parsing, not resolution, if possible. Your tests seem to rely on the implicit "default
might be fine. You'd just resolve So I think it would be helpful to separate validation of package names (which as I stated in #38, I would rather not do) from validation of paths. This would indeed cause validation errors if you use the implicit As for how we should validate paths: I wonder if we can lean on the URL spec here. The definitions around https://url.spec.whatwg.org/#url-path-segment-string seem helpful. Those definitions are intentionally stricter than what browsers parse; they are what are considered "valid" URLs, mostly for use by conformance checkers or similar things. But we could use that framework to start out restrictive. |
Sure, I've updated the basic type validations to happen on initialization of the package map. For now I've kept the package name validation to happen in this phase as well, until we can work out how to handle these cases. I do think it would be better to carefully restrict package names to sensible cases by disallowing internal dot segments and trailing slashes, also in terms of users understanding the difference between package names and URLs. While yes these apply to the "package names as path" cases, they are still interpretations of the package name. Paths can be looser by definition so I do very much see these as package name validations. For example, if a user were to mistakenly provide a URL-like into a package name (absolute URL, dot seegments). I've added the leading separator and URL case as well as a validation for now to demonstrate the usability here, which I think would be a nice cue for users to understand package names as something different. If we do decide to go with more loose package name interpretations allowing these things without the stricter validations, that still leaves us with the trailing slash case which is problematic -
|
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, looks great! We'll start here and perhaps get more restrictive over time.
I've tried to apply some of the cases mentioned in #11 to the reference implementation and managed to get some odd results for perusal.
Happy to discuss possible solutions here or in #11.
Great work @justinfagnani, the source is a pleasure to read and I was almost worried for a second there you'd managed to elegantly avoid all the edge case issues giving me nothing to complain about :)