getInnerRequest.js 813 B

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