Refactor url-utils package
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 134
- Forks
- 87
- Avg merge
- 12m
- Merged PRs (30d)
- 25
Description
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 (https://github.com/TryGhost/Ghost-SDK/pull/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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading index.js and mapping the interactions among getSubdir, deduplicateSubDir, and urlJoin. Research and discuss the proposed extraction and wrapper approaches, especially preserving the existing urlJoin API. Done means the package is split into smaller, as-pure-as-possible functions without changing its public behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100