mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 01:06:01 +03:00
73fdbba59c
This was a workaround to be able to build on case-insensitive file systems where it might get confused about <string.h> vs <String.h>. Let's just not support building that way, so String.h can have an objectively nicer name. :^)
47 lines
845 B
C++
47 lines
845 B
C++
#pragma once
|
|
|
|
#include <AK/String.h>
|
|
#include <AK/StringView.h>
|
|
|
|
namespace AK {
|
|
|
|
class URL {
|
|
public:
|
|
URL() {}
|
|
URL(const StringView&);
|
|
URL(const char* string)
|
|
: URL(StringView(string))
|
|
{
|
|
}
|
|
URL(const String& string)
|
|
: URL(string.view())
|
|
{
|
|
}
|
|
|
|
bool is_valid() const { return m_valid; }
|
|
String protocol() const { return m_protocol; }
|
|
String host() const { return m_host; }
|
|
String path() const { return m_path; }
|
|
u16 port() const { return m_port; }
|
|
|
|
String to_string() const;
|
|
|
|
private:
|
|
bool parse(const StringView&);
|
|
|
|
bool m_valid { false };
|
|
u16 m_port { 80 };
|
|
String m_protocol;
|
|
String m_host;
|
|
String m_path;
|
|
};
|
|
|
|
}
|
|
|
|
using AK::URL;
|
|
|
|
inline const LogStream& operator<<(const LogStream& stream, const URL& value)
|
|
{
|
|
return stream << value.to_string();
|
|
}
|