LibURL: Implement Site concept

This commit is contained in:
Sam Atkins 2024-11-27 16:47:14 +00:00 committed by Andreas Kling
commit b83f015c70
Notes: github-actions[bot] 2024-11-30 11:23:42 +00:00
6 changed files with 146 additions and 1 deletions

View file

@ -6,9 +6,27 @@
#include <LibURL/Origin.h>
#include <LibURL/Parser.h>
#include <LibURL/Site.h>
namespace URL {
// https://html.spec.whatwg.org/multipage/browsers.html#same-site
bool Origin::is_same_site(Origin const& other) const
{
// 1. Let siteA be the result of obtaining a site given A.
auto site_a = Site::obtain(*this);
// 2. Let siteB be the result of obtaining a site given B.
auto site_b = Site::obtain(other);
// 3. If siteA is same site with siteB, then return true.
if (site_a.is_same_site(site_b))
return true;
// 4. Return false.
return false;
}
// https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin
String Origin::serialize() const
{