|
64 | 64 | // Example: ['Mario', 'Toad'] (sorry Luigi)
|
65 | 65 | define('ADMINS', []);
|
66 | 66 |
|
| 67 | +// Strip file extensions from generated URLs |
| 68 | +// This is only useful if you have a rewrite rule |
| 69 | +define('URL_STRIP_EXTENSION', false); |
| 70 | + |
67 | 71 | // Log requests to Discord using a webhook
|
68 | 72 | // If you do not know what this is about, please ignore
|
69 | 73 | // It is not recommended to set this if your API is heavily used
|
@@ -180,6 +184,16 @@ function check_constants()
|
180 | 184 | 'Invalid ADMINS constant, must be an array.');
|
181 | 185 | }
|
182 | 186 |
|
| 187 | + if (!defined('URL_STRIP_EXTENSION')) |
| 188 | + { |
| 189 | + define('URL_STRIP_EXTENSION', false); |
| 190 | + } |
| 191 | + if (gettype(URL_STRIP_EXTENSION) !== 'boolean') |
| 192 | + { |
| 193 | + error_die($data, 500, 'invalid_server_configuration', |
| 194 | + 'Invalid URL_STRIP_EXTENSION constant, must be a boolean.'); |
| 195 | + } |
| 196 | + |
183 | 197 | if (!defined('DISCORD_WEBHOOK_URL'))
|
184 | 198 | {
|
185 | 199 | define('DISCORD_WEBHOOK_URL', '');
|
@@ -466,6 +480,11 @@ function generate_all_urls(&$data, $deletion = true)
|
466 | 480 |
|
467 | 481 | $data['url'] = "$protocol$domain$sub$name";
|
468 | 482 |
|
| 483 | + if (URL_STRIP_EXTENSION) |
| 484 | + { |
| 485 | + $data['url'] = preg_replace('/\.[^.]+$/', '', $data['url']); |
| 486 | + } |
| 487 | + |
469 | 488 | if (!$deletion)
|
470 | 489 | {
|
471 | 490 | return;
|
@@ -741,7 +760,7 @@ function info_endpoint(&$data)
|
741 | 760 | }
|
742 | 761 | }
|
743 | 762 |
|
744 |
| -define('VERSION', '2.2.1'); |
| 763 | +define('VERSION', '2.3.0'); |
745 | 764 | define('SOURCE', 'https://github.com/Xenthys/ShareXen');
|
746 | 765 |
|
747 | 766 | $data = [
|
|
0 commit comments