Skip to content

Commit

Permalink
Merge pull request #110 from momijizukamori/remove-url-defaults
Browse files Browse the repository at this point in the history
Make URLs slightly cleaner
  • Loading branch information
momijizukamori authored Apr 13, 2024
2 parents 7424d3d + 7291954 commit 83e6478
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bookbinder",
"version": "1.3.7",
"version": "1.4.0",
"description": "An app to rearrange PDF pages for printing for bookbinding",
"type": "module",
"scripts": {
Expand Down
8 changes: 5 additions & 3 deletions src/models/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ export const schema = z.object({
bottomEdgePaddingPt: urlSafe(z.coerce.number()).default(0),
sigFormat,
sigLength: urlSafe(z.coerce.number()).default(4), // Specific to standard
customSigLength: urlSafe(commaSeparatedNumberList).default([]), // Specific to custom.
customSigLength: urlSafe(commaSeparatedNumberList).default(null), // Specific to custom.
foreEdgePaddingPt: urlSafe(z.coerce.number()).default(0), // specific to wacky small
wackySpacing, // specific to wacky small
flyleafs: urlSafe(z.coerce.number()).default(1),
paperSizeCustomWidth: urlSafe(z.coerce.number()),
paperSizeCustomHeight: urlSafe(z.coerce.number()),
paperSizeCustomWidth: urlSafe(z.coerce.number()).default(0),
paperSizeCustomHeight: urlSafe(z.coerce.number()).default(0),
});

/** @typedef {z.infer<typeof schema>} Configuration */

export const defaultConfig = schema.parse({});
7 changes: 7 additions & 0 deletions src/utils/uri.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

import { defaultConfig } from '../models/configuration';

/**
* Gets parameters from a URL.
* @param { string } url The URL to get the params from
Expand All @@ -26,6 +28,11 @@ export const setUrlParams = (url, params) => {
continue;
}

if (value === defaultConfig[key]) {
urlRepresentation.searchParams.delete(key);
continue;
}

urlRepresentation.searchParams.set(key, String(value));
}

Expand Down

0 comments on commit 83e6478

Please sign in to comment.