summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-06 13:35:58 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-06 14:14:43 +0200
commit52fcaae71cb278c00f18247cf77a6a3c39ebf5df (patch)
treeb61ef04054db4f6d773d8062ca57e6743b3f348b /Libraries
parent5c0ee72b30062e4d659108579fdedc597cf89c18 (diff)
downloadserenity-52fcaae71cb278c00f18247cf77a6a3c39ebf5df.zip
LibWeb: Make Document::url() return URL by value
Returning it by reference can lead to unpleasant situations if we use this getter when the document may go away. Better to make the getter return a copy than have to think about this everywhere.
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibWeb/Bindings/LocationObject.cpp2
-rw-r--r--Libraries/LibWeb/DOM/Document.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/Libraries/LibWeb/Bindings/LocationObject.cpp b/Libraries/LibWeb/Bindings/LocationObject.cpp
index 7864f54efc..27dddc64d7 100644
--- a/Libraries/LibWeb/Bindings/LocationObject.cpp
+++ b/Libraries/LibWeb/Bindings/LocationObject.cpp
@@ -84,7 +84,7 @@ JS::Value LocationObject::hostname_getter(JS::Interpreter& interpreter)
JS::Value LocationObject::host_getter(JS::Interpreter& interpreter)
{
auto& window = static_cast<WindowObject&>(interpreter.global_object());
- auto& url = window.impl().document().url();
+ auto url = window.impl().document().url();
StringBuilder builder;
builder.append(url.host());
builder.append(':');
diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h
index 5ae6e1fb17..1b4172100f 100644
--- a/Libraries/LibWeb/DOM/Document.h
+++ b/Libraries/LibWeb/DOM/Document.h
@@ -53,7 +53,7 @@ public:
virtual ~Document() override;
void set_url(const URL& url) { m_url = url; }
- const URL& url() const { return m_url; }
+ URL url() const { return m_url; }
Origin origin() const;