HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/elite/node_modules/gulp-sourcemaps/src/utils.js
'use strict';
var path = require('path'),
  detectNewline = require('detect-newline');

function unixStylePath(filePath) {
  return filePath.split(path.sep).join('/');
}

var PLUGIN_NAME = require('../package.json').name;

var urlRegex = /^(https?|webpack(-[^:]+)?):\/\//;

var debug = require('./debug').spawn('utils');
/*
So reusing the same ref for a regex (with global (g)) is from a poor decision in js.
See http://stackoverflow.com/questions/10229144/bug-with-regexp-in-javascript-when-do-global-search

So we either need to use a new instance of a regex everywhere.
*/
var sourceMapUrlRegEx = function(){ return /\/\/\# sourceMappingURL\=.*/g;};

var commentFormatters = {
  css: function cssCommentFormatter(preLine, newline, url) {
    return preLine + "/*# sourceMappingURL=" + url + " */" + newline;
  },
  js: function jsCommentFormatter(preLine, newline, url) {
    return preLine + "//# sourceMappingURL=" + url + newline;
  },
  'default': function defaultFormatter() {
    return '';
  }
}


var getCommentFormatter = function (file) {
  var extension = file.relative.split('.').pop(),
    fileContents = file.contents.toString(),
    newline = detectNewline.graceful(fileContents || '');

  var commentFormatter = commentFormatters.default;

  if (file.sourceMap.preExistingComment) {
    commentFormatter = (commentFormatters[extension] || commentFormatter).bind(undefined, '', newline)
    debug(function () {
      return 'preExistingComment commentFormatter ' + commentFormatter.name;
    });
  } else {
    commentFormatter = (commentFormatters[extension] || commentFormatter).bind(undefined, newline, newline);
  }

  debug(function () {
    return 'commentFormatter ' + commentFormatter.name;
  });
  return commentFormatter;
};

var getInlinePreExisting = function(fileContent){
  if(sourceMapUrlRegEx().test(fileContent)){
    debug(function() { return 'has preExisting'; });
    return fileContent.match(sourceMapUrlRegEx())[0];
  }
};

var exceptionToString = function (exception) {
  return exception.message || '';
};

module.exports = {
  unixStylePath: unixStylePath,
  PLUGIN_NAME: PLUGIN_NAME,
  urlRegex: urlRegex,
  sourceMapUrlRegEx: sourceMapUrlRegEx,
  getCommentFormatter: getCommentFormatter,
  getInlinePreExisting: getInlinePreExisting,
  exceptionToString: exceptionToString
};