Skip to content

Refactor url-utils package #117

Open

Description

@naz

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.

Activity

  1. added
    enhancement
    help wanted
    on Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cleanupenhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions