jakerella / jquery-mockjax

The jQuery Mockjax Plugin provides a simple and extremely flexible interface for mocking or simulating ajax requests and responses
Other
2.12k stars 376 forks source link

Namespace to work with RegExp url patterns #357

Closed gregid closed 4 years ago

gregid commented 4 years ago

This addresses the #354

jakerella commented 4 years ago

I took a quick look, a couple things though:

  1. Looks like your auto-formatter took a pass at the readme, can you revert that please?
  2. What happens if the regex in the mock url matcher doesn't use the start-of-string character (^)? Is the namespace ignored? If so, this should be documented. But I'm wondering if we should prepend the namespace? If we were using string url matchers, it doesn't matter what the first character is. I think making the behavior match would be beneficial.
jakerella commented 4 years ago

Oh, and thanks for adding those tests! It makes the PR review much easier!

gregid commented 4 years ago
  1. Sorry, I didn't notice I had prettier on for markdown - will revert it.
  2. I'll try to make it prepend instead, should be as simple as:
    // changing this:
    handler.url.source.replace('^', '^('+ newNamespace +')?\/?') 
    // to:
    handler.url.source.replace(/^/, '^('+ newNamespace +')?\/?') 

    but will see in test

gregid commented 4 years ago

@jakerella namespace now works with RegExp matcher no matter the starting character.

jakerella commented 4 years ago

Looks pretty good! I'll try to get this out in a minor version release soon! Been real busy, and will be for another week+