Skip to content

Add urlPath function to internet module #3790

Open

Description

@ST-DDT

Clear and concise description of the problem

Currently there only exist method to generate an url consistent of the domain and protocol.
I would be nice, if there were also methods/parameters that would allow for generating url paths.

Suggested solution

urlPath(options: {
  depth?: number | { min: number; max: number; }
}: string;

Implementation either using /word/word or maybe using a new data set called url_path_words, as the urls may use English words even in non English locales.

Maybe include a path depth parameter in the url() function as well to include paths in the output.
(For a start defaults to zero in v10 and may be changed to a random length in v11)

Alternative

Use '/' + faker.word.words({ count: { min: 1, max: 5 } }).replaceAll(" ","/") instead.

Additional context

Split from #3785 for better clarity (url focus)

Activity

  1. added
    c: featureRequest for new feature
    m: internetSomething is referring to the internet module
    on Apr 6, 2026
  2. github-actions commented on Apr 6, 2026

    @github-actions
    Contributor

    Thank you for your feature proposal.

    We marked it as "waiting for user interest" for now to gather some feedback from our community:

    • If you would like to see this feature be implemented, please react to the description with an up-vote (:+1:).
    • If you have a suggestion or want to point out some special cases that need to be considered, please leave a comment, so we are aware about them.

    We would also like to hear about other community members' use cases for the feature to give us a better understanding of their potential implicit or explicit requirements.

    We will start the implementation based on:

    • the number of votes ( 👍 ) and comments
    • the relevance for the ecosystem
    • availability of alternatives and workarounds
    • and the complexity of the requested feature

    We do this because:

    • There are plenty of languages/countries out there and we would like to ensure that every method can cover all or almost all of them.
    • Every feature we add to faker has "costs" associated to it:
      • initial costs: design, implementation, reviews, documentation
      • running costs: awareness of the feature itself, more complex module structure, increased bundle size, more work during refactors

    View more issues which are waiting for user interest

  3. matthewmayer commented on Apr 7, 2026

    @matthewmayer
    Contributor

    i think we could use localized fake patterns to make this more realistic for web content, mixing in various patterns, depths, numbers, querystrings etc

    [
      '/',
      '/{{word.sample}}',
      '/{{word.sample}}/',
      '/{{word.sample}}/{{word.sample}}',
      '/{{word.sample}}/{{word.sample}}/',
      '/{{word.sample}}/{{word.sample}}/{{word.sample}}',
      '/{{word.sample}}/{{word.sample}}/{{word.sample}}/{{word.sample}}',
      '/{{word.sample}}/{{word.sample}}/{{word.sample}}/{{word.sample}}/{{word.sample}}',
      '/api/v{{number.int({ "min": 1, "max": 9 })}}/{{word.noun}}/{{string.uuid}}',
      '/categories/{{commerce.product}}/items',
      '/assets/img/{{system.commonFileName("png")}}',
      '/downloads/{{word.sample}}/{{system.commonFileName()}}',
      '/{{word.sample}}/index.html',
      '/users/{{internet.username}}/profile',
      '/u/{{number.int({ "min": 1000, "max": 9999 })}}/settings/security',
      '/account/billing/invoices/{{string.alphanumeric({ "length": 12, "casing": "upper" })}}',
      '/search?q={{word.sample}}&page={{number.int({ "min": 1, "max": 10 })}}',
      '/filter?category={{commerce.department}}&sort=desc',
      '/track?utm_source={{word.sample}}&utm_medium=email',
    ]
  4. ST-DDT commented on Apr 7, 2026

    @ST-DDT
    MemberAuthor

    I like the idea, but this would make it hard to implement arbritary depth parameters. Also ?... does not belong to the path.

    We could use url_path_words/patterns to store common chains though:

    [
    ['api', 'v{{number.int}}' ],
    ...
    ]
  5. matthewmayer commented on Apr 8, 2026

    @matthewmayer
    Contributor

    yeah that makes sense, you could have a variety of localized pathSegments, and then join together a random number of them with slashes.

    also once we have this working, we could extend faker.internet.url to optionally add a path

  6. added this to the vFuture milestone on Apr 8, 2026
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

    c: featureRequest for new featurehas workaroundWorkaround provided or linkedm: internetSomething is referring to the internet modules: waiting for user interestWaiting for more users interested in this feature

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions