JSFiddle - React, Tailwind, and code Playground

by Alexander Malinov

JavaScript

const url = 'lokosport://oauthredirect?code=b8553a902987f1f62219b542106eb8e97ef37488&scope=activity%3Aread%2Cread';


function getUrlParams(search) {
  let hashes = search.slice(search.indexOf('?') + 1).split('&')
  return hashes.reduce((params, hash) => {
      let [key, val] = hash.split('=')
      return Object.assign(params, {[key]: decodeURIComponent(val)})
  }, {})
}

console.log(getUrlParams(url))