mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-31 12:10:19 -07:00
UI Formatting Cleanup
This commit is contained in:
parent
b963f2aa82
commit
52e3d96f4a
110 changed files with 901 additions and 701 deletions
34
frontend/src/Utilities/String/parseUrl.js
Normal file
34
frontend/src/Utilities/String/parseUrl.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
import _ from 'lodash';
|
||||
import qs from 'qs';
|
||||
|
||||
// See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils
|
||||
const anchor = document.createElement('a');
|
||||
|
||||
export default function parseUrl(url) {
|
||||
anchor.href = url;
|
||||
|
||||
// The `origin`, `password`, and `username` properties are unavailable in
|
||||
// Opera Presto. We synthesize `origin` if it's not present. While `password`
|
||||
// and `username` are ignored intentionally.
|
||||
const properties = _.pick(
|
||||
anchor,
|
||||
'hash',
|
||||
'host',
|
||||
'hostname',
|
||||
'href',
|
||||
'origin',
|
||||
'pathname',
|
||||
'port',
|
||||
'protocol',
|
||||
'search'
|
||||
);
|
||||
|
||||
properties.isAbsolute = (/^[\w:]*\/\//).test(url);
|
||||
|
||||
if (properties.search) {
|
||||
// Remove leading ? from querystring before parsing.
|
||||
properties.params = qs.parse(properties.search.substring(1));
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue