Created
August 20, 2015 14:01
-
-
Save rufus2021/fe097433cb099b15ada4 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
// encode a particular part of a url | |
exports.encodeUrl = function encodeUrl(url, delimiter, keyword) { | |
var split = url.split(delimiter); | |
var container = []; | |
split.map(function (item) { | |
var replaced = keyword + '='; | |
if (item.indexOf(keyword) === 0) { | |
item = encodeURIComponent(item.split('=')[1]); | |
return container.push(replaced + item); | |
} | |
container.push(item); | |
}); | |
return container.join('&'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment