Commit Graph

9 Commits

Author SHA1 Message Date
Tim van der Meij
985ba77579
Modernize the remainder of the webserver's code and enable the no-var ESLint rule
This commit also moves the content type logic into a helper method to
ever so slightly reduce duplication.
2024-02-17 16:22:10 +01:00
Tim van der Meij
0015eb2431
Modernize the webserver's handler method
This commit converts `var` to `const`/`let`, gives the variables more
readable names and annotates the code to make the flow clearer.
2024-02-17 16:22:10 +01:00
Tim van der Meij
6ef813af01
Extract and modernize the webserver's request checking code
The `handler` method contained this code in two inline functions,
triggered via callbacks, which made the `handler` method big and harder
to read. Moreover, this code relied on variables from the outer scope,
which made it harder to reason about because the inputs and outputs
weren't easily visible.

This commit fixes the problems by extracting the request checking code
into a dedicated private method, and modernizing it to use e.g. `const`/
`let` instead of `var` and using template strings. The logic is now
self-contained in a single method that can be read from top to bottom
without callbacks and with comments annotating each check/section.
2024-02-17 16:22:10 +01:00
Tim van der Meij
ce4fe0c234
Extract and modernize the webserver's directory listing code
The `handler` method contained this code in an inline function, which
made the `handler` method big and harder to read. Moreover, this code
relied on variables from the outer scope, which made it harder to reason
about because the inputs and outputs weren't easily visible.

This commit fixes the problems by extracting the directory listing code
into a dedicated private method, and modernizing it to use e.g. `const`/
`let` instead of `var` and using template strings.
2024-02-11 20:06:21 +01:00
Tim van der Meij
336fcffd28
Extract and modernize the webserver's range file serving code
The `handler` method contained this code in an inline function, which
made the `handler` method big and harder to read. Moreover, this code
relied on variables from the outer scope, which made it harder to reason
about because the inputs and outputs weren't easily visible.

This commit fixes the problems by extracting the range file serving code
into a dedicated private method, and modernizing it to use e.g. `const`/
`let` instead of `var` and using template strings.
2024-02-11 17:04:38 +01:00
Tim van der Meij
56d9930a7b
Extract and modernize the webserver's file serving code
The `handler` method contained this code in an inline function, which
made the `handler` method big and harder to read. Moreover, this code
relied on variables from the outer scope, which made it harder to reason
about because the inputs and outputs weren't easily visible.

This commit fixes the problems by extracting the file serving code into
a dedicated private method, and modernizing it to use e.g. `const`/`let`
instead of `var` and using template strings.
2024-02-11 17:04:30 +01:00
Tim van der Meij
12b9685714
Convert the webserver to a proper class with private methods 2024-02-11 16:56:53 +01:00
Calixte Denizet
66982a2a11 [api-minor] Move to Fluent for the localization (bug 1858715)
- For the generic viewer we use @fluent/dom and @fluent/bundle
- For the builtin pdf viewer in Firefox, we set a localization url
  and then we rely on document.l10n which is a DOMLocalization object.
2023-10-19 11:20:41 +02:00
Jonas Jenwald
a209ce811d [ESM] Convert *most* of test-folder to use standard modules 2023-07-08 13:13:04 +02:00