source: frontend/node_modules/webpack/lib/RequestShortener.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const { contextify } = require("./util/identifier");
9
10/** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
11
12/**
13 * Shortens absolute or verbose request strings so diagnostics and stats output
14 * can be rendered relative to a chosen base directory.
15 */
16class RequestShortener {
17 /**
18 * Binds a context-aware shortening function to the provided directory and
19 * optional cache owner.
20 * @param {string} dir the directory
21 * @param {AssociatedObjectForCache=} associatedObjectForCache an object to which the cache will be attached
22 */
23 constructor(dir, associatedObjectForCache) {
24 this.contextify = contextify.bindContextCache(
25 dir,
26 associatedObjectForCache
27 );
28 }
29
30 /**
31 * Returns a request string rewritten relative to the configured directory
32 * when one is provided.
33 * @param {string | undefined | null} request the request to shorten
34 * @returns {string | undefined | null} the shortened request
35 */
36 shorten(request) {
37 if (!request) {
38 return request;
39 }
40 return this.contextify(request);
41 }
42}
43
44module.exports = RequestShortener;
Note: See TracBrowser for help on using the repository browser.