diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-04-13 04:34:50 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-04-13 04:34:50 +0800 |
| commit | 8449f5fcefc5406f1666257bacb3bb1afda978e1 (patch) | |
| tree | fe3dc5b34916f69b4aef6795d7f14abc298609e1 /src/core/browser.cc | |
| parent | 466e609d1a3c8efa4eea4b0fb4b1aeecd0d0706a (diff) | |
| download | rwebbrowser-8449f5fcefc5406f1666257bacb3bb1afda978e1.tar.gz rwebbrowser-8449f5fcefc5406f1666257bacb3bb1afda978e1.tar.xz | |
feat: implement configurable homepage and user-agent via config.txt
Diffstat (limited to 'src/core/browser.cc')
| -rw-r--r-- | src/core/browser.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/core/browser.cc b/src/core/browser.cc index dd96c7c..571783a 100644 --- a/src/core/browser.cc +++ b/src/core/browser.cc @@ -1003,6 +1003,21 @@ std::vector<std::string> wrap_lines( const std::vector<std::string>& original_li } // namespace +std::string Browser::get_configured_homepage() +{ + std::ifstream file( get_config_path( "config.txt" ) ); + if ( file.is_open() ) { + std::string line; + while ( std::getline( file, line ) ) { + const std::size_t eq = line.find( '=' ); + if ( eq != std::string::npos && line.substr( 0, eq ) == "homepage" ) { + return line.substr( eq + 1 ); + } + } + } + return "https://wikipedia.org"; +} + int Browser::run( std::string_view initial_url ) { std::vector<HttpRequest> history; |
