Skip to content

Commit

Permalink
Only escape things that absolutely need it, generate smaller URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Jul 9, 2023
1 parent 4b67b2a commit fe7a30d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/PackedBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fe7a30d

Please sign in to comment.