summaryrefslogtreecommitdiff
path: root/Libraries/LibHTML/DOM
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-18 22:04:39 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-19 17:46:36 +0100
commit0405ab91aaf22424b0ae28cba120b6b817a1afe0 (patch)
treec1fcb8c535fc7069e1c579d69449c68f56192dd1 /Libraries/LibHTML/DOM
parent47326042c5b13609b5a649d20e86a81121ded152 (diff)
downloadserenity-0405ab91aaf22424b0ae28cba120b6b817a1afe0.zip
LibHTML+AK: Move URL completion from Document to AK::URL
Completing a relative URL based on a base URL seems like generally useful functionality.
Diffstat (limited to 'Libraries/LibHTML/DOM')
-rw-r--r--Libraries/LibHTML/DOM/Document.cpp24
1 files changed, 1 insertions, 23 deletions
diff --git a/Libraries/LibHTML/DOM/Document.cpp b/Libraries/LibHTML/DOM/Document.cpp
index 5276c1804b..cdba807e77 100644
--- a/Libraries/LibHTML/DOM/Document.cpp
+++ b/Libraries/LibHTML/DOM/Document.cpp
@@ -156,29 +156,7 @@ RefPtr<GraphicsBitmap> Document::background_image() const
URL Document::complete_url(const String& string) const
{
- URL url(string);
- if (url.is_valid())
- return url;
-
- FileSystemPath fspath(m_url.path());
- StringBuilder builder;
- builder.append('/');
-
- bool document_url_ends_in_slash = m_url.path()[m_url.path().length() - 1] == '/';
-
- for (int i = 0; i < fspath.parts().size(); ++i) {
- if (i == fspath.parts().size() - 1 && !document_url_ends_in_slash)
- break;
- builder.append(fspath.parts()[i]);
- builder.append('/');
- }
- builder.append(string);
- auto built = builder.to_string();
- fspath = FileSystemPath(built);
-
- url = m_url;
- url.set_path(fspath.string());
- return url;
+ return m_url.complete_url(string);
}
void Document::force_layout()