You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
816 B

4 years ago
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. module.exports = function getInnerRequest(resolver, request) {
  7. if (
  8. typeof request.__innerRequest === "string" &&
  9. request.__innerRequest_request === request.request &&
  10. request.__innerRequest_relativePath === request.relativePath
  11. )
  12. return request.__innerRequest;
  13. let innerRequest;
  14. if (request.request) {
  15. innerRequest = request.request;
  16. if (/^\.\.?\//.test(innerRequest) && request.relativePath) {
  17. innerRequest = resolver.join(request.relativePath, innerRequest);
  18. }
  19. } else {
  20. innerRequest = request.relativePath;
  21. }
  22. request.__innerRequest_request = request.request;
  23. request.__innerRequest_relativePath = request.relativePath;
  24. return (request.__innerRequest = innerRequest);
  25. };