diff options
author | Marius David Wieschollek <passwords.public@mdns.eu> | 2020-12-23 14:27:52 +0300 |
---|---|---|
committer | Marius David Wieschollek <passwords.public@mdns.eu> | 2020-12-23 14:27:52 +0300 |
commit | 4644509da59a2794df5277461b1b8eedc02ab7eb (patch) | |
tree | 9fac0782528c785f2f2a8ae1760b03ede91532c3 /src | |
parent | 71f138364f84fe1a27db7e26cf3e685a149050c8 (diff) |
Replace need for dom element in url parser
Signed-off-by: Marius David Wieschollek <passwords.public@mdns.eu>
Diffstat (limited to 'src')
-rw-r--r-- | src/Classes/EnhancedApi.js | 19 | ||||
-rw-r--r-- | src/Classes/SimpleApi.js | 20 |
2 files changed, 19 insertions, 20 deletions
diff --git a/src/Classes/EnhancedApi.js b/src/Classes/EnhancedApi.js index 301b286..03c5a0d 100644 --- a/src/Classes/EnhancedApi.js +++ b/src/Classes/EnhancedApi.js @@ -1,3 +1,4 @@ +import Url from 'url-parse'; import SimpleApi from './SimpleApi'; import Encryption from './Encryption'; import EventEmitter from 'eventemitter3'; @@ -1355,4 +1356,22 @@ export default class EnhancedApi extends SimpleApi { } }; } + + // noinspection JSMethodCanBeStatic + /** + * + * @param url + * @param component + * @returns {*} + */ + parseUrl(url, component = null) { + if(url === undefined) return null; + + if(url.indexOf('://') === -1) url = `http://${url}`; + + let link = Url(url); + if(component !== null) return link[component]; + + return link; + } }
\ No newline at end of file diff --git a/src/Classes/SimpleApi.js b/src/Classes/SimpleApi.js index a9d569b..0a577c2 100644 --- a/src/Classes/SimpleApi.js +++ b/src/Classes/SimpleApi.js @@ -902,26 +902,6 @@ export default class SimpleApi { /** * * @param url - * @param component - * @returns {*} - */ - parseUrl(url, component = null) { - if(url === undefined) return null; - let link = document.createElement('a'); - - if(url.indexOf('://') === -1) url = `http://${url}`; - - link.setAttribute('href', url); - - if(component !== null) return link[component]; - - return link; - } - - // noinspection JSMethodCanBeStatic - /** - * - * @param url * @param data * @returns {*} */ |