mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
LibWeb/IDB: Implement is_valid_key_path
This commit is contained in:
parent
c276c212a0
commit
0979a154fd
Notes:
github-actions[bot]
2025-03-27 15:49:58 +00:00
Author: https://github.com/stelar7
Commit: 0979a154fd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4077
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta ✅
2 changed files with 36 additions and 0 deletions
|
@ -589,4 +589,36 @@ JS::Value convert_a_key_to_a_value(JS::Realm& realm, GC::Ref<Key> key)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#valid-key-path
|
||||
bool is_valid_key_path(KeyPath const& path)
|
||||
{
|
||||
// A valid key path is one of:
|
||||
return path.visit(
|
||||
[](String const& value) -> bool {
|
||||
// * An empty string.
|
||||
if (value.is_empty())
|
||||
return true;
|
||||
|
||||
// FIXME: * An identifier, which is a string matching the IdentifierName production from the ECMAScript Language Specification [ECMA-262].
|
||||
return true;
|
||||
|
||||
// FIXME: * A string consisting of two or more identifiers separated by periods (U+002E FULL STOP).
|
||||
return true;
|
||||
|
||||
return false;
|
||||
},
|
||||
[](Vector<String> const& values) -> bool {
|
||||
// * A non-empty list containing only strings conforming to the above requirements.
|
||||
if (values.is_empty())
|
||||
return false;
|
||||
|
||||
for (auto const& value : values) {
|
||||
if (!is_valid_key_path(value))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue