kiwix / kiwix-tools

Command line Kiwix tools: kiwix-serve, kiwix-manage, ...
https://download.kiwix.org/release/kiwix-tools/
GNU General Public License v3.0
428 stars 83 forks source link

Default kiwix-serve's rootLocation to "/" #571

Closed rgaudin closed 2 years ago

rgaudin commented 2 years ago

Usage mentions that the rootLocation defaults to / while it was not. It defaulted to an empty string.

While it defaulting to "" or "/" has no technical consequence: libkiwix's server normalizes the requested rootLocation ; it leads to users setting a "/"-prefixed rootLocation when customizing it, resulting in double-slashed print of the URL to access kiwix-serve at.

This harmonizes usage and actual default, fixing the URL print.

rgaudin commented 2 years ago

This change assumes that --urlRootLocation must be specified as an absolute path (starting with /). Omitting the leading / will still work but the printed URL will be absolutely incorrect. Better just strip the leading / (if any) from rootLocation.

You're right. I've copied the normalizeRootUrl function from libkiwix (server.m_root is private) so we can print a more reliable rootLocation… What do you think?