Skip to content

Commit f51e8e7

Browse files
tbhaxorawesomekling
authored andcommitted
Browser: Treat absolute path as local file
1 parent d6796d5 commit f51e8e7

File tree

1 file changed

+9
-0
lines changed
  • Userland/Applications/Browser

1 file changed

+9
-0
lines changed

Userland/Applications/Browser/Tab.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <Applications/Browser/TabGML.h>
2424
#include <Applications/BrowserSettings/Defaults.h>
2525
#include <LibConfig/Client.h>
26+
#include <LibFileSystem/FileSystem.h>
2627
#include <LibGUI/Action.h>
2728
#include <LibGUI/Application.h>
2829
#include <LibGUI/BoxLayout.h>
@@ -702,6 +703,14 @@ void Tab::update_reset_zoom_button()
702703
Optional<URL> Tab::url_from_location_bar(MayAppendTLD may_append_tld)
703704
{
704705
DeprecatedString text = m_location_box->text();
706+
if (text.starts_with('/') && FileSystem::is_regular_file(text)) {
707+
auto real_path = FileSystem::real_path(text);
708+
if (real_path.is_error()) {
709+
return {};
710+
}
711+
712+
return URL::create_with_file_scheme(real_path.value().to_deprecated_string());
713+
}
705714

706715
StringBuilder builder;
707716
builder.append(text);

0 commit comments

Comments
 (0)