You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
url-utils package has too many intermingled functions in a single index.js file.
Goal
Have package build from a set of smaller functions which would be as pure as possible.
Context
After extracting url-utils package from Ghost core (#114) it was hard to break up a package into smaller pieces right away. The main reason is calls between the functions are to dependent on one another. For example, the getSubdir method is being called almost from every function and sometimes is even nested as a call from deduplicateSubDir. Another pain point is urlJoin method, which operates on arguments directly and adding any parameters to it would need some more thinking (because it possibly could change existing API).
Possible approaches
To decouple methods from getSubdir it could be extracted into function parameters instead.
The urlJoin method could be wrapped to keep accepting no parameters. The wrapper would call internal urlJoinInternal method with first parameter as an options object containing subdir value: urlJoinInternal({subdir: getSubdir()}, ...arguments).
TODO
Possible approaches section needs more research and discussion.
The text was updated successfully, but these errors were encountered:
Problem
url-utils
package has too many intermingled functions in a singleindex.js
file.Goal
Have package build from a set of smaller functions which would be as pure as possible.
Context
After extracting
url-utils
package from Ghost core (#114) it was hard to break up a package into smaller pieces right away. The main reason is calls between the functions are to dependent on one another. For example, thegetSubdir
method is being called almost from every function and sometimes is even nested as a call fromdeduplicateSubDir
. Another pain point isurlJoin
method, which operates onarguments
directly and adding any parameters to it would need some more thinking (because it possibly could change existing API).Possible approaches
To decouple methods from
getSubdir
it could be extracted into function parameters instead.The
urlJoin
method could be wrapped to keep accepting no parameters. The wrapper would call internalurlJoinInternal
method with first parameter as an options object containing subdir value:urlJoinInternal({subdir: getSubdir()}, ...arguments)
.TODO
Possible approaches section needs more research and discussion.
The text was updated successfully, but these errors were encountered: