Blame view

node_modules/less/lib/less-browser/utils.js 1.21 KB
7820380e   “wangming”   1
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
  "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.addDataAttr = exports.extractId = void 0;
  function extractId(href) {
      return href.replace(/^[a-z-]+:\/+?[^/]+/, '') // Remove protocol & domain
          .replace(/[?&]livereload=\w+/, '') // Remove LiveReload cachebuster
          .replace(/^\//, '') // Remove root /
          .replace(/\.[a-zA-Z]+$/, '') // Remove simple extension
          .replace(/[^.\w-]+/g, '-') // Replace illegal characters
          .replace(/\./g, ':'); // Replace dots with colons(for valid id)
  }
  exports.extractId = extractId;
  function addDataAttr(options, tag) {
      if (!tag) {
          return;
      } // in case of tag is null or undefined
      for (var opt in tag.dataset) {
          if (Object.prototype.hasOwnProperty.call(tag.dataset, opt)) {
              if (opt === 'env' || opt === 'dumpLineNumbers' || opt === 'rootpath' || opt === 'errorReporting') {
                  options[opt] = tag.dataset[opt];
              }
              else {
                  try {
                      options[opt] = JSON.parse(tag.dataset[opt]);
                  }
                  catch (_) { }
              }
          }
      }
  }
  exports.addDataAttr = addDataAttr;
  //# sourceMappingURL=utils.js.map