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

Value::find() unable to handle paths where one of the segments contains a dot #109

Open
jasal82 opened this issue Jun 21, 2024 · 1 comment

Comments

@jasal82
Copy link

jasal82 commented Jun 21, 2024

For example, if I have the following (TOML) configuration:

[token]
"https://artifactory.mysite.com" = "12345"

then I would expect find_value(r#"token."https://artifactory.mysite.com""#) to succeed. Currently it throws a MissingField error. The implementation of Value::find() performs a simple split on the dot chars which is not enough in this case. A parser would have to be added which can correctly handle the quote scope.

@SergioBenitez
Copy link
Owner

It's not clear to me that we should have "foo.bar" mean something different than foo.bar, as far as our notion of "key paths" goes. In particular, since key paths are independent of any particular format, it would be odd to base them on TOML's idea of strings. However, I do agree that it's necessary to allow some way to escape the . character. Canonically, this would be \. with \ as the escape character.

As an aside, in retrospect, giving any special meaning to characters in this context feels like the wrong approach. Instead, it would have been nice to make these functions generic on their input type, allowing various types including strings (without special meaning to any character), slices of strings, and string iterators, removing the ambiguity and thus the need to resolve it:

value.find(["foo", "bar"])
value.find(&["foo", "bar"])
value.find("foo.bar".split('.'));
value.find("foo.bar"); // equivalent to value.find(["foo.bar"]);

In any case, I'll think about a good interim solution.

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

No branches or pull requests

2 participants