Skip to content

Parentheses in request URL handled differently between pretender and MSW #15

@mrloop

Description

@mrloop

MSW expects parentheses to be escaped in URLs but pretender does not. This prevents mirage-msw being a drop in replacement. Currently in my mirage setup I'm using a helper function to escape URL strings that contain parentheses if the test suite is running using mirage-msw. Migrating large number on mirage endpoint, small PR by small PR so need to support both MSW and pretender while migrating.

export default function mswEscapeUrl(stringUrl) {
  if (ENV.useMsw) {
    return stringUrl.replaceAll('(', '\\(').replaceAll(')', '\\)');
  }
  return stringUrl;
}

Here's the MSW test and mock showing this behaviour

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions