Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Refactor url-utils package #117

Open
naz opened this issue Jun 11, 2019 · 0 comments
Open

Refactor url-utils package #117

naz opened this issue Jun 11, 2019 · 0 comments
Labels
cleanup enhancement New feature or request help wanted Extra attention is needed

Comments

@naz
Copy link
Contributor

naz commented Jun 11, 2019

Problem

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.

@naz naz added enhancement New feature or request help wanted Extra attention is needed cleanup labels Jun 11, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
cleanup enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant