AK: Make URL::m_port an Optional<u16>, Expose raw port getter

Our current way of signalling a missing port with m_port == 0 was
lacking, as 0 is a valid port number in URLs.
This commit is contained in:
Idan Horowitz 2021-09-13 23:12:16 +03:00 committed by Andreas Kling
commit d6cfa34667
Notes: sideshowbarker 2024-07-18 03:59:28 +09:00
15 changed files with 42 additions and 41 deletions

View file

@ -74,7 +74,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::host_getter)
{
auto& window = static_cast<WindowObject&>(global_object);
auto url = window.impl().associated_document().url();
return JS::js_string(vm, String::formatted("{}:{}", url.host(), url.port()));
return JS::js_string(vm, String::formatted("{}:{}", url.host(), url.port_or_default()));
}
JS_DEFINE_NATIVE_FUNCTION(LocationObject::hash_getter)