Creates a cacheable response object from a Request and Response pair. This function serializes the response content based on its content type and generates a hash for the request to be used as a cache key.
Checks if a value is a full URL.
Encodes a string to be used in a URL.
Converts an HTML string to a DOM Document object.
Generates a unique hash for a given Request object based on its method, URL path, search parameters, and body. This hash can be used to identify and cache requests. This is used to store the mocked response body at a location with a unique filename (based on the hash). This is necessary because the only other way to differentiate between request really is to store the file in a location that contains the hostname, request method, request path and then some way to differentiate between the request body and parameters. But even trying that causes issues. Trying to dynamically import the file
./responses/${reqUrl.hostname}/${reqUrl.path}/${searchQuery}.json
throws the exception: