webpack/lib/RequestShortener.js

35 lines
755 B
JavaScript
Raw Normal View History

2013-01-31 01:49:25 +08:00
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
2018-07-30 23:08:51 +08:00
"use strict";
const { contextify } = require("./util/identifier");
class RequestShortener {
2018-11-24 04:50:26 +08:00
/**
* @param {string} dir the directory
* @param {object=} associatedObjectForCache an object to which the cache will be attached
2018-11-24 04:50:26 +08:00
*/
constructor(dir, associatedObjectForCache) {
this.contextify = contextify.bindContextCache(
dir,
associatedObjectForCache
);
2013-07-11 05:20:07 +08:00
}
2018-11-24 04:50:26 +08:00
/**
* @param {string | undefined | null} request the request to shorten
* @returns {string | undefined | null} the shortened request
*/
shorten(request) {
2018-11-24 04:50:26 +08:00
if (!request) {
return request;
}
return this.contextify(request);
2013-07-11 05:20:07 +08:00
}
2013-01-31 01:49:25 +08:00
}
module.exports = RequestShortener;