mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
LibWeb/IDB: Implement is_valid_key_path
This commit is contained in:
committed by
Jelle Raaijmakers
parent
c276c212a0
commit
0979a154fd
Notes:
github-actions[bot]
2025-03-27 15:49:58 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/0979a154fdd Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4077 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/gmta ✅
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user