Commit 6203cc2d authored by Flavio TARSETTI's avatar Flavio TARSETTI

Merge branch '522-view-reports-url' into 'master'

Fix malformed URLs when `URL_PREFIX` is set

Closes #522

See merge request !284
parents bb435ef6 a88b1d86
Pipeline #30286 passed with stages
in 19 minutes and 20 seconds
......@@ -1913,12 +1913,16 @@ beat.experiments.utils.modal_add_to_report = function(names, report_list_url) {
var type = BootstrapDialog.TYPE_PRIMARY;
var title = '<i class="fa fa-check"></i> Report changes';
var btn_type = 'btn-primary';
let viewReportUrl = `${$.ajaxSettings.url.split(
'/experiments'
)[0]}${select
.val()
.replace('add/', '')
.replace(/api\/v.\//, '')}`;
// regex to extract the path to the report that the user
// added the experiment(s) to
// URL fragments are like "/platform/api/v1/reports/user/test/add/"
// format is "<part of prefix>/reports/<user>/<report name>/add/"
// we want "reports/<user>/<report name>"
const rReportFragment = /^.*(reports\/[^\/]+\/[^\/]+)\/add\/$/;
const reportUrlFragment = rReportFragment.exec(select.val())[1];
const currPrefix = $.ajaxSettings.url.split('/experiments')[0];
let viewReportUrl = `${currPrefix}/${reportUrlFragment}`;
if (successful == sent) {
description.text(
`Successfully added ${sent} experiment(s) to report`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment