Last active
August 29, 2015 14:03
-
-
Save ayamomiji/0f47a41546d07827d1a7 to your computer and use it in GitHub Desktop.
This file contains 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
# 不考慮重複 key 和無 value 的情況 | |
parseQS = (qs = location.search) -> | |
object = {} | |
pairs = qs.substring(1) # 去除前置 ? 字元 | |
.split('&') # 變成一堆 oo=xx 字串 | |
for pair in pairs | |
[key, value] = pair.split('=') | |
object[key] = value | |
object | |
parseQS('?noel=yoona&foo=bar&yoona&foo=bar')['noel'] # => yoona |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment