A *nix check for the slash might be best. Otherwise, a broken url with two forward slashes is technically possible if someone provides a path that end in a slash via MATHJAX_DIR (and we automatically append one in all cases).
Why is there nothing as handy as Python's os.path.join, so we could avoid concatenating with slashes altogether?