url-query.ts 408 B

123456789101112
  1. /**
  2. * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. export function urlQueryParameter (id: string) {
  7. if (typeof window === 'undefined') return undefined
  8. const a = new RegExp(`${id}=([^&#=]*)`)
  9. const m = a.exec(window.location.search)
  10. return m ? decodeURIComponent(m[1]) : undefined
  11. }