-
Notifications
You must be signed in to change notification settings - Fork 11
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
Non URI file scheme equal type name support #688
Changes from 19 commits
8e72c9b
bd9e0c3
8fced5e
fab82a6
ae14c69
f3b2330
4485b9f
7433063
555ca0b
7173d9a
b89fbdb
f3c80d6
3b3472a
ebd8ace
67312cc
3fb00eb
53f4f52
f1937d8
b9aba4a
42aecf7
6213f43
a5ae80c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -559,4 +559,20 @@ cosim::filesystem::path file_uri_to_path(const uri& fileUri) | |
} | ||
|
||
|
||
cosim::filesystem::path file_query_uri_to_path( | ||
const cosim::uri& baseUri, | ||
const cosim::uri& queryUri) | ||
{ | ||
const auto query = queryUri.query(); | ||
if (query && query->find("file=") < query->size()) { | ||
if (query->find("file=file:///") < query->size()) { | ||
return file_uri_to_path(std::string(query->substr(5))); | ||
} | ||
const auto uriToAppend = cosim::path_to_file_uri(cosim::file_uri_to_path(baseUri).parent_path()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better for readability if this function just gets the parent of baseUri as the first argument, rather than computing it here. I think the function signature might mislead users that it will use the full baseUri for computing the final path There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with the reasoning and if this was an isolated case it would make sense to rename it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this would be an improvement to readability and/or usability of the code, then I'd say just do it. No need to rely on adherence to a similar implementation elsewhere (in fact, perhaps that too should be updated). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New commit with |
||
return file_uri_to_path(std::string(uriToAppend.view()) + "/" + std::string(query->substr(5))); | ||
} | ||
return file_uri_to_path(baseUri).parent_path(); | ||
} | ||
|
||
|
||
} // namespace cosim |
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.
Would this effectively tie us down to the "classical" three slashes file URI scheme only? Sounds to me like it is now considered optional, quote from RFC 8089:
https://www.rfc-editor.org/rfc/rfc8089#appendix-A
Should we take into account that the file URI may be of the form
file:/
also?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.
In that case I think there also have to be made changes to
proxy_uri_sub_resolver::lookup_model
for consistency.file:///
in the query is used there to distinguish between relative and absolute path. Report as separate issue?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.
Let's do that then. There are a couple other things I'm skeptical about in the resolvers, like the reliance on
substr(specific_number)
. Should be worth a closer look.