mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 14:33:22 +00:00
Fix URL strings for query parameter method
This commit is contained in:
@@ -7,7 +7,8 @@ import Persist from './stores/Persist';
|
||||
import Header from './components/Header';
|
||||
import Tooltip from './components/Tooltip';
|
||||
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 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/:code?', (r) => this._setPage(OutfittingPage, 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('/about', (r) => this._setPage(AboutPage, r));
|
||||
Router('*', (r) => this._setPage(null, r));
|
||||
|
||||
@@ -345,7 +345,7 @@ export default class ComparisonPage extends Page {
|
||||
|
||||
let code = fromComparison(name, builds, selectedFacets, predicate, desc);
|
||||
let loc = window.location;
|
||||
return `${loc.protocol}//${loc.host}/comparison/${code}`;
|
||||
return loc.protocol + '//' + loc.host + '/comparison?code=' + encodeURIComponent(code);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -289,6 +289,8 @@ export default class OutfittingPage extends Page {
|
||||
sStr = ship.getStandardString() + '.' + ship.getModificationsString(),
|
||||
iStr = ship.getInternalString() + '.' + ship.getModificationsString();
|
||||
|
||||
Router.replace(outfitURL(ship.id, code, buildName));
|
||||
|
||||
return (
|
||||
<div id='outfit' className={'page'} style={{ fontSize: (sizeRatio * 0.9) + 'em' }}>
|
||||
<div id='overview'>
|
||||
|
||||
@@ -211,13 +211,13 @@ export function toDetailedExport(builds) {
|
||||
* @return {string} Zipped Base 64 encoded JSON
|
||||
*/
|
||||
export function fromComparison(name, builds, facets, predicate, desc) {
|
||||
return Utils.toUrlSafe(LZString.compressToBase64(JSON.stringify({
|
||||
return LZString.compressToBase64(JSON.stringify({
|
||||
n: name,
|
||||
b: builds.map((b) => { return { s: b.id, n: b.buildName, c: b.toString() }; }),
|
||||
f: facets,
|
||||
p: predicate,
|
||||
d: desc ? 1 : 0
|
||||
})));
|
||||
}));
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1199,7 +1199,7 @@ export default class Ship {
|
||||
priorities.push(slot.priority);
|
||||
}
|
||||
|
||||
this.serialized.priorities = Utils.toUrlSafe(LZString.compressToBase64(priorities.join('')));
|
||||
this.serialized.priorities = LZString.compressToBase64(priorities.join(''));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1220,7 +1220,7 @@ export default class Ship {
|
||||
enabled.push(slot.enabled ? 1 : 0);
|
||||
}
|
||||
|
||||
this.serialized.enabled = Utils.toUrlSafe(LZString.compressToBase64(enabled.join('')));
|
||||
this.serialized.enabled = LZString.compressToBase64(enabled.join(''));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1387,7 +1387,7 @@ export default class Ship {
|
||||
buffer.writeInt8(-1, curpos++);
|
||||
}
|
||||
|
||||
this.serialized.modifications = Utils.toUrlSafe(zlib.gzipSync(buffer).toString('base64'));
|
||||
this.serialized.modifications = zlib.gzipSync(buffer).toString('base64');
|
||||
} else {
|
||||
this.serialized.modifications = null;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
if (module.getModValue('rof')) {
|
||||
|
||||
@@ -60,16 +60,11 @@ export function shallowEqual(objA, objB) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a base-64 encoded string in to a URL-safe version
|
||||
* @param {string} data the string
|
||||
* @return {string} the converted string
|
||||
*/
|
||||
export function toUrlSafe(data) {
|
||||
return data ? data.replace(/\//g, '-').replace(/\+/g, '_') : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a URL-safe base-64 encoded string in to a normal version
|
||||
* Turn a URL-safe base-64 encoded string in to a normal version.
|
||||
* Coriolis used to use a different encoding system, and some old
|
||||
* 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
|
||||
* be safe.
|
||||
* @param {string} data the string
|
||||
* @return {string} the converted string
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user