Last active
June 28, 2021 19:52
-
-
Save narennaik/374eb0bece640eb21128d7be42542d52 to your computer and use it in GitHub Desktop.
using pipe
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
const getDomainName = (item) => item.details.name; | |
const getProtocol = (item) => (item.details.valid ? 'https' : 'http'); | |
const getUrl = (item) => `${getProtocol(item)}://${getDomainName(item)}`; | |
// TODO: (temporary) Adding callback=true because server side redirection needs this parameter | |
const addCallbackParameter = (url) => `${url}?callback=true`; | |
const generateUrl = (item) => { | |
const url = getUrl(item); | |
const urlWithCallbackParameter = addCallbackParameter(url); | |
return urlWithCallbackParameter; | |
}; | |
// The above function can be simplified or created using pipe utility function from ramda. | |
const generateUrl = R.pipe(getUrl, addCallbackParameter); | |
const urlList = domainList.map(generateUrl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment