Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: add support for wildcards (*) in URL #31

Merged
merged 1 commit into from
May 21, 2021
Merged

Conversation

lukaszfiszer
Copy link
Collaborator

@lukaszfiszer lukaszfiszer commented May 11, 2021

Switching away from path-to-regexp, as it has non-intuitive support for wildcards. It requires a regex-style wildcard asterisk: /example/(.*)

Url-pattern (https://www.npmjs.com/package/url-pattern) library support both path parameters and simpler wildcard asterisks

test/integration/mockiavelli.int.test.ts Show resolved Hide resolved
ctx.mockiavelli.mock('*/example/', { status: 200 });
jest.spyOn(console, 'error').mockImplementation(() => {});

await expect(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also http://external-source/api/example/ ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that does not work actually. It is because the hostname and path are matched separately, and only the path part is matched using patterns. To change that a bigger refactor would be needed, which is out of scope of this PR

@lukaszfiszer lukaszfiszer merged commit 93215da into mock-no-found May 21, 2021
@lukaszfiszer lukaszfiszer deleted the wildcards branch May 21, 2021 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants