Centralise query string generation & fallback to hash if too long
parent
c70008ede3
commit
a9b69fd6f5
|
@ -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;
|
||||
|
|
|
@ -147,11 +147,10 @@ THE SOFTWARE.
|
|||
<script>
|
||||
import PrettyCheck from 'pretty-checkbox-vue/check';
|
||||
import Modal from 'do-vue/src/templates/modal';
|
||||
import qs from 'qs';
|
||||
import i18n from '../../i18n';
|
||||
import delegatedFromDefaults from '../../util/delegated_from_defaults';
|
||||
import computedFromDefaults from '../../util/computed_from_defaults';
|
||||
import exportData from '../../util/export_data';
|
||||
import shareQuery from '../../util/share_query';
|
||||
|
||||
const defaults = {
|
||||
modularizedStructure: {
|
||||
|
@ -190,18 +189,17 @@ THE SOFTWARE.
|
|||
return this.$parent.$parent.activeDomains.length > 0;
|
||||
},
|
||||
shareQuery() {
|
||||
const data = exportData(this.$parent.$parent.activeDomains, this.$parent.$props.data);
|
||||
return qs.stringify(data, { allowDots: true });
|
||||
return shareQuery(this.$parent.$parent.activeDomains, this.$parent.$props.data);
|
||||
},
|
||||
shareLink() {
|
||||
const base = `${window.location.protocol}//${window.location.host}${window.location.pathname}`;
|
||||
return `${base}${this.shareQuery.length ? '?' : ''}${this.shareQuery}`;
|
||||
return `${base}${this.shareQuery}`;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
// When the share link changes, update the site query
|
||||
shareQuery(query) {
|
||||
window.history.replaceState({}, '', `?${query}`);
|
||||
window.history.replaceState({}, '', query);
|
||||
},
|
||||
// Disable symlink if modularized structure is disabled
|
||||
'$props.data.modularizedStructure': {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
Copyright 2020 DigitalOcean
|
||||
|
||||
This code is licensed under the MIT License.
|
||||
You may obtain a copy of the License at
|
||||
https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import qs from 'qs';
|
||||
import exportData from './export_data';
|
||||
|
||||
export default (domains, global) => {
|
||||
const data = exportData(domains, global);
|
||||
const query = qs.stringify(data, { allowDots: true });
|
||||
return `${query.length > 4000 ? '#' : ''}${query.length ? '?' : ''}${query}`;
|
||||
};
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
Copyright 2020 DigitalOcean
|
||||
|
||||
|
|
Loading…
Reference in New Issue