mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
AK: Add URL::basename()
This commit is contained in:
parent
68abc103f7
commit
ae047649db
Notes:
sideshowbarker
2024-07-19 06:56:43 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ae047649db5
2 changed files with 8 additions and 0 deletions
|
@ -366,4 +366,11 @@ URL URL::create_with_url_or_path(const String& url_or_path)
|
|||
return URL::create_with_file_protocol(path);
|
||||
}
|
||||
|
||||
String URL::basename() const
|
||||
{
|
||||
if (!m_valid)
|
||||
return {};
|
||||
return FileSystemPath(m_path).basename();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
1
AK/URL.h
1
AK/URL.h
|
@ -61,6 +61,7 @@ public:
|
|||
void set_fragment(const String& fragment);
|
||||
void set_port(u16 port) { m_port = port; }
|
||||
|
||||
String basename() const;
|
||||
String to_string() const;
|
||||
|
||||
URL complete_url(const String&) const;
|
||||
|
|
Loading…
Add table
Reference in a new issue