]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/helpers/utils/url.ts
Added filter to sort videos by name (alphabetical order)
[github/Chocobozzz/PeerTube.git] / client / src / app / helpers / utils / url.ts
index 82d9cc11b47a95b67acec529fbbd453e9dc32584..08c27e3c1e907c9ebb6e746f13ecb6bc2fbc8f88 100644 (file)
@@ -1,19 +1,5 @@
 import { environment } from '../../../environments/environment'
 
-// Thanks: https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
-function getParameterByName (name: string, url: string) {
-  if (!url) url = window.location.href
-  name = name.replace(/[[\]]/g, '\\$&')
-
-  const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)')
-  const results = regex.exec(url)
-
-  if (!results) return null
-  if (!results[2]) return ''
-
-  return decodeURIComponent(results[2].replace(/\+/g, ' '))
-}
-
 function getAbsoluteAPIUrl () {
   let absoluteAPIUrl = environment.hmr === true
     ? 'http://localhost:9000'
@@ -27,6 +13,10 @@ function getAbsoluteAPIUrl () {
   return absoluteAPIUrl
 }
 
+function getAPIHost () {
+  return new URL(getAbsoluteAPIUrl()).host
+}
+
 function getAbsoluteEmbedUrl () {
   let absoluteEmbedUrl = environment.originServerUrl
   if (!absoluteEmbedUrl) {
@@ -64,8 +54,8 @@ function objectToFormData (obj: any, form?: FormData, namespace?: string) {
 }
 
 export {
-  getParameterByName,
   objectToFormData,
   getAbsoluteAPIUrl,
+  getAPIHost,
   getAbsoluteEmbedUrl
 }