'a'
mh-two-thousand-and-two
2024-04-12 44d2c92345cd156a59fc327b3060292a282d2893
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"use strict";
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = loader;
exports.raw = void 0;
 
var _loaderUtils = require("loader-utils");
 
var _schemaUtils = _interopRequireDefault(require("schema-utils"));
 
var _mime = _interopRequireDefault(require("mime"));
 
var _normalizeFallback = _interopRequireDefault(require("./utils/normalizeFallback"));
 
var _options = _interopRequireDefault(require("./options.json"));
 
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
/* eslint-disable
  global-require,
  no-param-reassign,
  prefer-destructuring,
  import/no-dynamic-require,
*/
function shouldTransform(limit, size) {
  if (typeof limit === 'boolean') {
    return limit;
  }
 
  if (typeof limit === 'string') {
    return size <= parseInt(limit, 10);
  }
 
  if (typeof limit === 'number') {
    return size <= limit;
  }
 
  return true;
}
 
function loader(src) {
  // Loader Options
  const options = (0, _loaderUtils.getOptions)(this) || {};
  (0, _schemaUtils.default)(_options.default, options, {
    name: 'URL Loader',
    baseDataPath: 'options'
  }); // No limit or within the specified limit
 
  if (shouldTransform(options.limit, src.length)) {
    const file = this.resourcePath; // Get MIME type
 
    const mimetype = options.mimetype || _mime.default.getType(file);
 
    if (typeof src === 'string') {
      src = Buffer.from(src);
    }
 
    return `${options.esModules ? 'export default' : 'module.exports ='} ${JSON.stringify(`data:${mimetype || ''};base64,${src.toString('base64')}`)}`;
  } // Normalize the fallback.
 
 
  const {
    loader: fallbackLoader,
    options: fallbackOptions
  } = (0, _normalizeFallback.default)(options.fallback, options); // Require the fallback.
 
  const fallback = require(fallbackLoader); // Call the fallback, passing a copy of the loader context. The copy has the query replaced. This way, the fallback
  // loader receives the query which was intended for it instead of the query which was intended for url-loader.
 
 
  const fallbackLoaderContext = Object.assign({}, this, {
    query: fallbackOptions
  });
  return fallback.call(fallbackLoaderContext, src);
} // Loader Mode
 
 
const raw = true;
exports.raw = raw;