localBaseUrlOf static method
Creates the base URL for a Publication locally served through HTTP, from the
publication's filename
and the HTTP server port
.
Note: This is used for backward-compatibility, but ideally this should be handled by the Server, and set in the self Link. Unfortunately, the self Link is not available in the navigator at the moment without changing the code in reading apps.
Implementation
static String localBaseUrlOf(String filename, int port) {
String sanitizedFilename = filename
.removePrefix("/")
.hashWith(crypto.md5)
.let((it) => Uri.encodeComponent(it));
return "http://127.0.0.1:$port/$sanitizedFilename";
}