mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 10:42:45 +00:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									5c0ee72b30
								
							
						
					
					
						commit
						52fcaae71c
					
				
					 2 changed files with 2 additions and 2 deletions
				
			
		|  | @ -84,7 +84,7 @@ JS::Value LocationObject::hostname_getter(JS::Interpreter& interpreter) | ||||||
| JS::Value LocationObject::host_getter(JS::Interpreter& interpreter) | JS::Value LocationObject::host_getter(JS::Interpreter& interpreter) | ||||||
| { | { | ||||||
|     auto& window = static_cast<WindowObject&>(interpreter.global_object()); |     auto& window = static_cast<WindowObject&>(interpreter.global_object()); | ||||||
|     auto& url = window.impl().document().url(); |     auto url = window.impl().document().url(); | ||||||
|     StringBuilder builder; |     StringBuilder builder; | ||||||
|     builder.append(url.host()); |     builder.append(url.host()); | ||||||
|     builder.append(':'); |     builder.append(':'); | ||||||
|  |  | ||||||
|  | @ -53,7 +53,7 @@ public: | ||||||
|     virtual ~Document() override; |     virtual ~Document() override; | ||||||
| 
 | 
 | ||||||
|     void set_url(const URL& url) { m_url = url; } |     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; |     Origin origin() const; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling