Skip to content

Commit efbfd7b

Browse files
authored
Allow ScriptReportPage.saveReport to return null (#2546)
1 parent 6e4d1ba commit efbfd7b

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/org/labkey/test/pages/reports/ScriptReportPage.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
import org.openqa.selenium.WebElement;
1818
import org.openqa.selenium.support.ui.ExpectedConditions;
1919

20+
import java.net.URLDecoder;
21+
import java.nio.charset.StandardCharsets;
2022
import java.util.Map;
21-
import java.util.Objects;
2223
import java.util.Optional;
2324

2425
import static org.labkey.test.components.ext4.Checkbox.Ext4Checkbox;
@@ -89,12 +90,25 @@ public String saveReport(String name, boolean isSaveAs, int wait)
8990
{
9091
saveReportWithName(name, isSaveAs);
9192
}
92-
return Objects.requireNonNullElse(getReportId(), reportIdBeforeSave);
93+
String reportIdAfterSave = getReportId();
94+
return reportIdAfterSave == null ? reportIdBeforeSave : reportIdAfterSave;
9395
}
9496

9597
public String getReportId()
9698
{
97-
return getUrlParam("reportId", true);
99+
String paramName = "reportId";
100+
101+
Map<String, String> params = WebTestHelper.parseUrlQuery(getURL());
102+
String paramValue = params.get(paramName);
103+
104+
if (paramValue == null)
105+
{
106+
paramValue = params.entrySet().stream()
107+
.filter(entry -> entry.getKey().endsWith("." + paramName))
108+
.map(Map.Entry::getValue).findFirst().orElse(null);
109+
}
110+
111+
return paramValue == null ? null : URLDecoder.decode(paramValue, StandardCharsets.UTF_8);
98112
}
99113

100114
/**

0 commit comments

Comments
 (0)