+/* Construction of Game API endpoint paths. Logically all endpoints
+ * are just local resources underneath the current path, but just
+ * referring to them by a local name only works if the current path
+ * has a trailing slash.
+ *
+ * That is, if the current path is:
+ *
+ * https://lmno.games/empires/WXYZ/
+ *
+ * Then a path of "register" goes to:
+ *
+ * https://lmno.games/empires/WXYZ/register
+ *
+ * Just as we want. But if the current path happens to be:
+ *
+ * https://lmno.games/empires/WXYZ
+ *
+ * Then a path of "register" goes to:
+ *
+ * https://lmno.games/empires/register
+ *
+ * Which cannot work since we have lost the game ID in the path.
+ *
+ * Of course, we would like to have canonical URLs for the game (with
+ * the trailing slash) but since that depends on macehinery outside
+ * the scope of this file, let's construct API paths that will work
+ * either way.
+ */
+function GAME_API(endpoint) {
+ var path = window.location.pathname;
+ if (! path.endsWith('/'));
+ path += '/';
+ path += endpoint;
+ return path;
+}
+