Created
August 18, 2019 07:23
-
-
Save kadoshita/dff7aa9b287ba132e057fac798b48ce0 to your computer and use it in GitHub Desktop.
URLのクエリパラメータをいい感じにオブジェクトにして返すメソッド
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parseQueryParameter(query: string): { [key: string]: string } { | |
let params: Array<string> = query.split('&'); | |
let paramObject: { [key: string]: string } = {}; | |
params.forEach(p => { | |
let key = p.split('=')[0]; | |
let value = p.split('=')[1]; | |
paramObject[key] = value; | |
}); | |
return paramObject; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment