Last change
on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
755 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | Author Tobias Koppers @sokra
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | "use strict";
|
---|
| 7 |
|
---|
| 8 | const { contextify } = require("./util/identifier");
|
---|
| 9 |
|
---|
| 10 | class RequestShortener {
|
---|
| 11 | /**
|
---|
| 12 | * @param {string} dir the directory
|
---|
| 13 | * @param {object=} associatedObjectForCache an object to which the cache will be attached
|
---|
| 14 | */
|
---|
| 15 | constructor(dir, associatedObjectForCache) {
|
---|
| 16 | this.contextify = contextify.bindContextCache(
|
---|
| 17 | dir,
|
---|
| 18 | associatedObjectForCache
|
---|
| 19 | );
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | /**
|
---|
| 23 | * @param {string | undefined | null} request the request to shorten
|
---|
| 24 | * @returns {string | undefined | null} the shortened request
|
---|
| 25 | */
|
---|
| 26 | shorten(request) {
|
---|
| 27 | if (!request) {
|
---|
| 28 | return request;
|
---|
| 29 | }
|
---|
| 30 | return this.contextify(request);
|
---|
| 31 | }
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | module.exports = RequestShortener;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.