mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:28:12 +00:00
Browser: Be a little bit smarter about interpretering command line URLs
If the (optional) URL specified on the command line is an existing file we now resolve its real path before turning into a URL. This makes relative URLs inside the loaded document work correctly. Also interpret all other specified URLs the same way we would if you had typed them into the location bar.
This commit is contained in:
parent
d54ace5f04
commit
68ae1de463
2 changed files with 33 additions and 17 deletions
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/StringBuilder.h>
|
||||
#include "BookmarksBarWidget.h"
|
||||
#include "InspectorWidget.h"
|
||||
#include "Tab.h"
|
||||
|
@ -46,6 +47,7 @@ namespace Browser {
|
|||
static const char* bookmarks_filename = "/home/anon/bookmarks.json";
|
||||
String g_home_url;
|
||||
bool g_use_old_html_parser = false;
|
||||
URL url_from_user_input(const String& input);
|
||||
|
||||
}
|
||||
|
||||
|
@ -183,8 +185,13 @@ int main(int argc, char** argv)
|
|||
};
|
||||
|
||||
URL first_url = Browser::g_home_url;
|
||||
if (specified_url)
|
||||
first_url = URL::create_with_url_or_path(specified_url);
|
||||
if (specified_url) {
|
||||
if (Core::File::exists(specified_url)) {
|
||||
first_url = URL::create_with_file_protocol(Core::File::real_path_for(specified_url));
|
||||
} else {
|
||||
first_url = Browser::url_from_user_input(specified_url);
|
||||
}
|
||||
}
|
||||
|
||||
window_actions.on_create_new_tab = [&] {
|
||||
create_new_tab(Browser::g_home_url, true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue