feature/strip-identifier (#25)

* Ignore non-alphanumeric chars finding project by identifier

* Add babel plugin nullish coallescing operator

* Refactor

* Add projectId to remote services
This commit is contained in:
Manuel Bouza
2019-10-10 14:38:28 +02:00
committed by Tobias Miesel
parent 53be150788
commit 7023b4b482
5 changed files with 54 additions and 19 deletions

View File

@@ -23,6 +23,7 @@ export const ERROR_UNKNOWN = "unknown"
export const noop = () => null
export const asArray = input => (Array.isArray(input) ? input : [input])
export const removeNonAlphanumChars = input => String(input ?? "").replace(/[\W_]/g, "")
export const findProjectBy = prop => val => projects => {
if (!val) {
@@ -30,7 +31,11 @@ export const findProjectBy = prop => val => projects => {
}
return compose(
find(pathEq(prop, val)),
find(
project =>
project[prop] === val ||
removeNonAlphanumChars(project[prop]) === removeNonAlphanumChars(val),
),
flatMap(get("options")),
)(projects)
}