Input and Output character encodings are now stored in the URL, allowing for accuate deeplinking

This commit is contained in:
n1474335 2022-09-16 19:24:57 +01:00
parent a141873db8
commit a07b8f693b
5 changed files with 51 additions and 30 deletions

View file

@ -451,6 +451,7 @@ class App {
* Searches the URI parameters for recipe and input parameters.
* If recipe is present, replaces the current recipe with the recipe provided in the URI.
* If input is present, decodes and sets the input to the one provided in the URI.
* If character encodings are present, sets them appropriately.
* If theme is present, uses the theme.
*
* @fires Manager#statechange
@ -490,6 +491,16 @@ class App {
} catch (err) {}
}
// Input Character Encoding
if (this.uriParams.ienc) {
this.manager.input.chrEncChange(parseInt(this.uriParams.ienc, 10));
}
// Output Character Encoding
if (this.uriParams.oenc) {
this.manager.output.chrEncChange(parseInt(this.uriParams.oenc, 10));
}
// Read in theme from URI params
if (this.uriParams.theme) {
this.manager.options.changeTheme(Utils.escapeHtml(this.uriParams.theme));
@ -731,19 +742,19 @@ class App {
debounce(function() {
this.progress = 0;
this.autoBake();
this.updateTitle(true, null, true);
this.updateURL(true, null, true);
}, 20, "stateChange", this, [])();
}
/**
* Update the page title to contain the new recipe
* Update the page title and URL to contain the new recipe
*
* @param {boolean} includeInput
* @param {string} input
* @param {string} [input=null]
* @param {boolean} [changeUrl=true]
*/
updateTitle(includeInput, input, changeUrl=true) {
updateURL(includeInput, input=null, changeUrl=true) {
// Set title
const recipeConfig = this.getRecipeConfig();
let title = "CyberChef";