addEventListener("fetch", event => {
  // Get the request from the client.
  const req = event.request;
  // Parse the URL from client request.
  const url = new URL(req.url);

  // Patttern match the URL with RegularExpression.
  let complexUrlRegex = new RegExp("^\/some-(custom|dynamic|complex)-pattern\/url\/path$", "g");
  let complexUrlMatch= complexUrlRegex.exec(url.pathname);
  
  // If the URL matches the pattern, rewrite URL path.
  if (complexUrlMatch) {
    url.pathname = "/status/200";
  } 
  let bereq = new Request(url, req);
  
  // Send request to origin and return response to client.
  return fetch(bereq, { backend: "origin_0" });
});