Centralise query string generation & fallback to hash if too long

This commit is contained in:
MattIPv4
2020-06-05 17:16:26 +01:00
parent c70008ede3
commit a9b69fd6f5
4 changed files with 41 additions and 12 deletions

View File

@@ -24,19 +24,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import qs from 'qs';
import sslProfiles from '../../util/ssl_profiles';
import exportData from '../../util/export_data';
import websiteConf from './website.conf';
import shareQuery from '../../util/share_query';
export default (domains, global) => {
const config = {};
// Source
config['# Generated by nginxconfig.io'] = '';
const data = exportData(domains.map((domain, index) => [domain, index]).filter(d => d[0] !== null), global);
const query = qs.stringify(data, { allowDots: true });
config[`# ${window.location.protocol}//${window.location.host}${window.location.pathname}${query.length ? '?' : ''}${query}`] = '';
const query = shareQuery(domains.map((domain, index) => [domain, index]).filter(d => d[0] !== null), global);
config[`# ${window.location.protocol}//${window.location.host}${window.location.pathname}${query}`] = '';
// Basic nginx conf
config.user = global.nginx.user.computed;