Skip to content

Add a leading / if the path doesn't have it #1259

@kevinnio

Description

@kevinnio

Recently, we bumped into an issue with nock in which it won't catch a request we were sure was being mocked correctly. We were wondering for a while until .log(console.log) shed some light on what the issue was.

We noticed our host url didn't have a trailing slash (http://localhost:3000) while at the same time our mocked path didn't have a leading slash (api/bot/request.json). Turns out knock was trying to match our url with http://localhost:3000api/bot/request.json, no slash separating the host and path segments.

I was wondering if we can have nock add that slash by itself when is not present.

I can submit a PR if you guys want.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions