Produce ;\n, but still take in old format

This commit is contained in:
Ilya Ig. Petrov 2017-10-31 18:43:30 +05:00
parent 41913e7dad
commit 18d3dda63e

View File

@ -161,10 +161,11 @@ export default function getProxyEditor(theState) {
const splitBySemi = (proxyString) => proxyString const splitBySemi = (proxyString) => proxyString
.replace(/#.*$/mg, '') .replace(/#.*$/mg, '')
.trim() .trim()
.split(/\s*;\r?\n\s*/g) .split(/\s*;\s*/g)
.map((s) => s.trim())
.filter((s) => s); .filter((s) => s);
const joinBySemi = (strs) => strs.join(';\n') + ';\n'; const joinBySemi = (strs) => strs.join(';\n');
const normalizeProxyString = (str) => joinBySemi(splitBySemi(str)); const normalizeProxyString = (str) => joinBySemi(splitBySemi(str));
const PROXY_TYPE_LABEL_PAIRS = [['PROXY', 'PROXY/HTTP'],['HTTPS'],['SOCKS4'],['SOCKS5'],['SOCKS']]; const PROXY_TYPE_LABEL_PAIRS = [['PROXY', 'PROXY/HTTP'],['HTTPS'],['SOCKS4'],['SOCKS5'],['SOCKS']];
@ -225,8 +226,8 @@ export default function getProxyEditor(theState) {
const crededHostname = elements.newHostname; const crededHostname = elements.newHostname;
const port = elements.newPort; const port = elements.newPort;
const newValue = `${that.props.proxyStringRaw}; ${type} ${crededHostname}:${port}` const newValue = `${that.props.proxyStringRaw};\n${type} ${crededHostname}:${port}`
.trim().replace(/(\s*;\s*)+/, '; '); .trim().replace(/(\s*;\s*)+/, ';\n');
that.props.setProxyStringRaw(true, newValue); that.props.setProxyStringRaw(true, newValue);
} }