+/**
+ * Removes undesired query parameters and fragments
+ *
+ * @param string url Url to be cleaned
+ *
+ * @return string the string representation of this URL after cleanup
+ */
+function cleanup_url($url)
+{
+ $obj_url = new Url($url);
+ return $obj_url->cleanup();
+}
+
+/**
+ * Get URL scheme.
+ *
+ * @param string url Url for which the scheme is requested
+ *
+ * @return mixed the URL scheme or false if none is provided.
+ */
+function get_url_scheme($url)
+{
+ $obj_url = new Url($url);
+ return $obj_url->getScheme();
+}
+
+/**
+ * Adds a trailing slash at the end of URL if necessary.
+ *
+ * @param string $url URL to check/edit.
+ *
+ * @return string $url URL with a end trailing slash.
+ */
+function add_trailing_slash($url)
+{
+ return $url . (!endsWith($url, '/') ? '/' : '');
+}
+/**
+ * Converts an URL with an IDN host to a ASCII one.
+ *
+ * @param string $url Input URL.
+ *
+ * @return string converted URL.
+ */
+function url_with_idn_to_ascii($url)
+{
+ $parts = parse_url($url);
+ $parts['host'] = idn_to_ascii($parts['host']);
+
+ $httpUrl = new \http\Url($parts);
+ return $httpUrl->toString();
+}