2019-01-02 04:24:12 -06:00
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2024-01-01 02:43:48 -06:00
|
|
|
// Copyright (C) 2013 - 2024, The pgAdmin Development Team
|
2019-01-02 04:24:12 -06:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2023-10-23 07:13:17 -05:00
|
|
|
const endpoints = require('pgadmin.browser.endpoints');
|
|
|
|
|
|
|
|
module.exports = function(endpoint, substitutions) {
|
|
|
|
let rawURL = endpoints[endpoint];
|
|
|
|
|
|
|
|
// captures things of the form <path:substitutionName>
|
2024-06-11 07:37:22 -05:00
|
|
|
let substitutionGroupsRegExp = /(<)([^:^>]*:)?([^>]+)(>)/g,
|
2023-10-23 07:13:17 -05:00
|
|
|
interpolated = rawURL;
|
|
|
|
|
|
|
|
if (!rawURL)
|
|
|
|
return rawURL;
|
|
|
|
|
|
|
|
interpolated = interpolated.replace(
|
|
|
|
substitutionGroupsRegExp,
|
|
|
|
function(_origin, _1, _2, substitutionName) {
|
|
|
|
if (substitutionName in substitutions) {
|
|
|
|
return substitutions[substitutionName];
|
2017-06-12 01:31:22 -05:00
|
|
|
}
|
2023-10-23 07:13:17 -05:00
|
|
|
return _origin;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
return interpolated;
|
|
|
|
};
|