doc/_static: match with branch encoded in pathname in URL

since we've migrated to RTD, a typical URL of ceph document looks like

https://docs.ceph.com/en/octopus/rados/

so instead of match "/docs.ceph.com/docs/<branch-name>/", we should
better match "/en/<branch-name>". in this change,

* do not include the domain name in the pattern to be matched,
  it's not necessary.
* match with "/en/<branch-name>/"

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2020-11-20 12:51:56 +08:00
parent e5c949dbe9
commit 0980cde334

View File

@ -20,8 +20,8 @@ $(function() {
}
function get_branch() {
var url = window.location.href;
var res = url.match(/docs.ceph.com\/docs\/([a-z]+)\/?/i)
var pathname = window.location.pathname;
var res = pathname.match(/en\/([a-z]+)\/?/i)
if (res) {
return res[1]
}