| Server IP : 34.87.99.72 / Your IP : 216.73.217.31 Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 User : bitnami ( 1000) PHP Version : 7.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /opt/bitnami/apache/htdocs/app/node_modules/webpack-dev-middleware/dist/utils/ |
Upload File : |
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getFilenameFromUrl;
var _path = _interopRequireDefault(require("path"));
var _url = require("url");
var _querystring = _interopRequireDefault(require("querystring"));
var _mem = _interopRequireDefault(require("mem"));
var _getPaths = _interopRequireDefault(require("./getPaths"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const memoizedParse = (0, _mem.default)(_url.parse);
function getFilenameFromUrl(context, url) {
const {
options
} = context;
const paths = (0, _getPaths.default)(context);
let filename;
let urlObject;
try {
// The `url` property of the `request` is contains only `pathname`, `search` and `hash`
urlObject = memoizedParse(url, false, true);
} catch (_ignoreError) {
return filename;
}
for (const {
publicPath,
outputPath
} of paths) {
let publicPathObject;
try {
publicPathObject = memoizedParse(publicPath !== 'auto' && publicPath ? publicPath : '/', false, true);
} catch (_ignoreError) {
// eslint-disable-next-line no-continue
continue;
}
if (urlObject.pathname && urlObject.pathname.startsWith(publicPathObject.pathname)) {
filename = outputPath; // Strip the `pathname` property from the `publicPath` option from the start of requested url
// `/complex/foo.js` => `foo.js`
const pathname = urlObject.pathname.substr(publicPathObject.pathname.length);
if (pathname) {
filename = _path.default.join(outputPath, _querystring.default.unescape(pathname));
}
let fsStats;
try {
fsStats = context.outputFileSystem.statSync(filename);
} catch (_ignoreError) {
// eslint-disable-next-line no-continue
continue;
}
if (fsStats.isFile()) {
break;
} else if (fsStats.isDirectory() && (typeof options.index === 'undefined' || options.index)) {
const indexValue = typeof options.index === 'undefined' || typeof options.index === 'boolean' ? 'index.html' : options.index;
filename = _path.default.join(filename, indexValue);
try {
fsStats = context.outputFileSystem.statSync(filename);
} catch (__ignoreError) {
// eslint-disable-next-line no-continue
continue;
}
if (fsStats.isFile()) {
break;
}
}
}
}
return filename;
}