refactor: remove deprecated url.parse() method (#7751)
This commit is contained in:
16
src/batch.js
16
src/batch.js
@@ -1,5 +1,4 @@
|
||||
const Parse = require('parse/node').Parse;
|
||||
const url = require('url');
|
||||
const path = require('path');
|
||||
// These methods handle batch requests.
|
||||
const batchPath = '/batch';
|
||||
@@ -11,11 +10,12 @@ function mountOnto(router) {
|
||||
});
|
||||
}
|
||||
|
||||
function parseURL(URL) {
|
||||
if (typeof URL === 'string') {
|
||||
return url.parse(URL);
|
||||
function parseURL(urlString) {
|
||||
try {
|
||||
return new URL(urlString);
|
||||
} catch(error) {
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function makeBatchRoutingPathFunction(originalUrl, serverURL, publicServerURL) {
|
||||
@@ -33,9 +33,9 @@ function makeBatchRoutingPathFunction(originalUrl, serverURL, publicServerURL) {
|
||||
return path.posix.join('/', requestPath.slice(apiPrefix.length));
|
||||
};
|
||||
|
||||
if (serverURL && publicServerURL && serverURL.path != publicServerURL.path) {
|
||||
const localPath = serverURL.path;
|
||||
const publicPath = publicServerURL.path;
|
||||
if (serverURL && publicServerURL && serverURL.pathname != publicServerURL.pathname) {
|
||||
const localPath = serverURL.pathname;
|
||||
const publicPath = publicServerURL.pathname;
|
||||
|
||||
// Override the api prefix
|
||||
apiPrefix = localPath;
|
||||
|
||||
Reference in New Issue
Block a user