From fe7a30dbc4dc61db3e89c13253cd6c499e790af8 Mon Sep 17 00:00:00 2001 From: Doug Wright Date: Sun, 9 Jul 2023 20:11:06 +0100 Subject: [PATCH] Only escape things that absolutely need it, generate smaller URLs --- src/PackedBox.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/PackedBox.php b/src/PackedBox.php index 36fb027..9b0c88a 100644 --- a/src/PackedBox.php +++ b/src/PackedBox.php @@ -14,11 +14,16 @@ use function json_encode; use function max; use function round; -use function urlencode; use function is_iterable; use function count; use function array_pop; use function assert; +use function rawurlencode; + +use const JSON_THROW_ON_ERROR; +use const JSON_NUMERIC_CHECK; +use const JSON_UNESCAPED_UNICODE; +use const JSON_UNESCAPED_SLASHES; /** * A "box" with items. @@ -173,7 +178,7 @@ public function getVolumeUtilisation(): float */ public function generateVisualisationURL(): string { - return 'https://boxpacker.io/en/master/visualiser.html?packing=' . urlencode(json_encode($this)); + return 'https://boxpacker.io/en/master/visualiser.html?packing=' . rawurlencode(json_encode($this, flags: JSON_THROW_ON_ERROR | JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); } public function __construct(protected Box $box, protected PackedItemList $items)