Fix profile/alternative loading

This commit is contained in:
Gautier Pelloux-Prayer 2017-05-03 21:34:01 +02:00
parent 5bd679a282
commit 595ac34d58
3 changed files with 28 additions and 20 deletions

View file

@ -47,13 +47,17 @@ L.BRouter = L.Class.extend({
if (this.options.profile != null)
params.profile = this.options.profile;
// do not put alternative in URL if it has its default value,
// but always set it if we want to generate route because Brouter API requires it.
if (this.options.alternative != 0 || format != null)
params.alternativeidx = this.options.alternative;
params.alternativeidx = this.options.alternative;
if (format != null)
if (format != null) {
params.format = format;
} else {
// do not put values in URL if this is the default value (format===null)
if (params.profile === BR.conf.profiles[0])
delete params.profile;
if (params.alternativeidx == 0)
delete params.alternativeidx;
}
return params;
},