aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/misc/utils.ts
blob: 2b5c3686ebf10add63d088c6376e20acfa1cd099 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 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, ' '))
}

export {
  getParameterByName
}