Fix URL strings for query parameter method

This commit is contained in:
Cmdr McDonald
2016-11-21 11:33:34 +00:00
parent 24abd6583f
commit 95b7d60be4
7 changed files with 20 additions and 17 deletions

View File

@@ -7,7 +7,8 @@ import Persist from './stores/Persist';
import Header from './components/Header'; import Header from './components/Header';
import Tooltip from './components/Tooltip'; import Tooltip from './components/Tooltip';
import ModalImport from './components/ModalImport'; import ModalImport from './components/ModalImport';
import * as Utils from './utils/UtilityFunctions'; import * as CompanionApiUtils from './utils/CompanionApiUtils';
import { outfitURL } from './utils/UrlGenerators'
import AboutPage from './pages/AboutPage'; import AboutPage from './pages/AboutPage';
import NotFoundPage from './pages/NotFoundPage'; import NotFoundPage from './pages/NotFoundPage';
@@ -73,6 +74,7 @@ export default class Coriolis extends React.Component {
Router('/outfit/:ship/?', (r) => this._setPage(OutfittingPage, r)); Router('/outfit/:ship/?', (r) => this._setPage(OutfittingPage, r));
Router('/outfit/:ship/:code?', (r) => this._setPage(OutfittingPage, r)); Router('/outfit/:ship/:code?', (r) => this._setPage(OutfittingPage, r));
Router('/compare/:name?', (r) => this._setPage(ComparisonPage, r)); Router('/compare/:name?', (r) => this._setPage(ComparisonPage, r));
Router('/comparison?', (r) => this._setPage(ComparisonPage, r));
Router('/comparison/:code', (r) => this._setPage(ComparisonPage, r)); Router('/comparison/:code', (r) => this._setPage(ComparisonPage, r));
Router('/about', (r) => this._setPage(AboutPage, r)); Router('/about', (r) => this._setPage(AboutPage, r));
Router('*', (r) => this._setPage(null, r)); Router('*', (r) => this._setPage(null, r));

View File

@@ -345,7 +345,7 @@ export default class ComparisonPage extends Page {
let code = fromComparison(name, builds, selectedFacets, predicate, desc); let code = fromComparison(name, builds, selectedFacets, predicate, desc);
let loc = window.location; let loc = window.location;
return `${loc.protocol}//${loc.host}/comparison/${code}`; return loc.protocol + '//' + loc.host + '/comparison?code=' + encodeURIComponent(code);
} }
/** /**

View File

@@ -289,6 +289,8 @@ export default class OutfittingPage extends Page {
sStr = ship.getStandardString() + '.' + ship.getModificationsString(), sStr = ship.getStandardString() + '.' + ship.getModificationsString(),
iStr = ship.getInternalString() + '.' + ship.getModificationsString(); iStr = ship.getInternalString() + '.' + ship.getModificationsString();
Router.replace(outfitURL(ship.id, code, buildName));
return ( return (
<div id='outfit' className={'page'} style={{ fontSize: (sizeRatio * 0.9) + 'em' }}> <div id='outfit' className={'page'} style={{ fontSize: (sizeRatio * 0.9) + 'em' }}>
<div id='overview'> <div id='overview'>

View File

@@ -211,13 +211,13 @@ export function toDetailedExport(builds) {
* @return {string} Zipped Base 64 encoded JSON * @return {string} Zipped Base 64 encoded JSON
*/ */
export function fromComparison(name, builds, facets, predicate, desc) { export function fromComparison(name, builds, facets, predicate, desc) {
return Utils.toUrlSafe(LZString.compressToBase64(JSON.stringify({ return LZString.compressToBase64(JSON.stringify({
n: name, n: name,
b: builds.map((b) => { return { s: b.id, n: b.buildName, c: b.toString() }; }), b: builds.map((b) => { return { s: b.id, n: b.buildName, c: b.toString() }; }),
f: facets, f: facets,
p: predicate, p: predicate,
d: desc ? 1 : 0 d: desc ? 1 : 0
}))); }));
}; };
/** /**

View File

@@ -1199,7 +1199,7 @@ export default class Ship {
priorities.push(slot.priority); priorities.push(slot.priority);
} }
this.serialized.priorities = Utils.toUrlSafe(LZString.compressToBase64(priorities.join(''))); this.serialized.priorities = LZString.compressToBase64(priorities.join(''));
return this; return this;
} }
@@ -1220,7 +1220,7 @@ export default class Ship {
enabled.push(slot.enabled ? 1 : 0); enabled.push(slot.enabled ? 1 : 0);
} }
this.serialized.enabled = Utils.toUrlSafe(LZString.compressToBase64(enabled.join(''))); this.serialized.enabled = LZString.compressToBase64(enabled.join(''));
return this; return this;
} }
@@ -1387,7 +1387,7 @@ export default class Ship {
buffer.writeInt8(-1, curpos++); buffer.writeInt8(-1, curpos++);
} }
this.serialized.modifications = Utils.toUrlSafe(zlib.gzipSync(buffer).toString('base64')); this.serialized.modifications = zlib.gzipSync(buffer).toString('base64');
} else { } else {
this.serialized.modifications = null; this.serialized.modifications = null;
} }

View File

@@ -355,6 +355,10 @@ function _addModifications(module, modifiers) {
} }
} }
// Jitter is an absolute number, so we need to divide it by 100
if (module.getModValue('jitter')) {
module.setModValue('jitter', module.getModValue('jitter') / 100);
}
// FD uses interval between bursts internally, so we need to translate this to a real rate of fire // FD uses interval between bursts internally, so we need to translate this to a real rate of fire
if (module.getModValue('rof')) { if (module.getModValue('rof')) {

View File

@@ -60,16 +60,11 @@ export function shallowEqual(objA, objB) {
} }
/** /**
* Turn a base-64 encoded string in to a URL-safe version * Turn a URL-safe base-64 encoded string in to a normal version.
* @param {string} data the string * Coriolis used to use a different encoding system, and some old
* @return {string} the converted string * data might be bookmarked or on local storage, so we keep this
*/ * around and use it when decoding data from the old-style URLs to
export function toUrlSafe(data) { * be safe.
return data ? data.replace(/\//g, '-').replace(/\+/g, '_') : null;
}
/**
* Turn a URL-safe base-64 encoded string in to a normal version
* @param {string} data the string * @param {string} data the string
* @return {string} the converted string * @return {string} the converted string
*/ */