@@ -15,24 +15,27 @@ namespace Web::HTML {
1515// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator-appversion
1616String NavigatorIDMixin::app_version () const
1717{
18- auto navigator_compatibility_mode = ResourceLoader::the ().navigator_compatibility_mode ();
18+ // 1. Let userAgent be this's relevant settings object's environment default `User-Agent` value.
19+ // FIXME: Store that on the settings object?
20+ auto user_agent = ResourceLoader::the ().user_agent ();
1921
20- // Must return the appropriate string that starts with "5.0 (", as follows:
22+ // 2. If userAgent does not start with `Mozilla/5.0 (`, then return the empty string.
23+ if (!user_agent.starts_with_bytes (" Mozilla/5.0 (" sv))
24+ return {};
2125
22- // Let trail be the substring of default `User-Agent` value that follows the "Mozilla/" prefix.
23- auto user_agent_string = ResourceLoader::the ().user_agent ();
24- auto trail = MUST (user_agent_string.substring_from_byte_offset (strlen (" Mozilla/" ), user_agent_string.bytes ().size () - strlen (" Mozilla/" )));
26+ // 3. Let trail be the substring of userAgent, isomorphic decoded, that follows the "Mozilla/" prefix.
27+ auto trail = MUST (user_agent.substring_from_byte_offset (" Mozilla/" sv.length ()));
2528
26- // If the navigator compatibility mode is Chrome or WebKit
29+ // 4. -> If the navigator compatibility mode is Chrome or WebKit
30+ auto navigator_compatibility_mode = ResourceLoader::the ().navigator_compatibility_mode ();
2731 if (navigator_compatibility_mode == NavigatorCompatibilityMode::Chrome || navigator_compatibility_mode == NavigatorCompatibilityMode::WebKit) {
2832 // Return trail.
2933 return trail;
3034 }
31-
32- // If the navigator compatibility mode is Gecko
35+ // -> If the navigator compatibility mode is Gecko
3336 if (navigator_compatibility_mode == NavigatorCompatibilityMode::Gecko) {
3437 // If trail starts with "5.0 (Windows", then return "5.0 (Windows)".
35- if (trail.starts_with_bytes (" 5.0 (Windows" sv, CaseSensitivity::CaseSensitive ))
38+ if (trail.starts_with_bytes (" 5.0 (Windows" sv))
3639 return " 5.0 (Windows)" _string;
3740
3841 // Otherwise, return the prefix of trail up to but not including the first U+003B (;), concatenated with the
0 commit comments