middleware-route-matcher.js 850 B

1234567891011121314151617181920212223242526
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getMiddlewareRouteMatcher = getMiddlewareRouteMatcher;
  6. var _prepareDestination = require("./prepare-destination");
  7. function getMiddlewareRouteMatcher(matchers) {
  8. return (pathname, req, query)=>{
  9. for (const matcher of matchers){
  10. const routeMatch = new RegExp(matcher.regexp).exec(pathname);
  11. if (!routeMatch) {
  12. continue;
  13. }
  14. if (matcher.has || matcher.missing) {
  15. const hasParams = (0, _prepareDestination).matchHas(req, query, matcher.has, matcher.missing);
  16. if (!hasParams) {
  17. continue;
  18. }
  19. }
  20. return true;
  21. }
  22. return false;
  23. };
  24. }
  25. //# sourceMappingURL=middleware-route-matcher.js.map