feat: Enhance RequestUrlUtils to handle browser Referer for public URL resolution and add corresponding unit tests

This commit is contained in:
2026-07-14 22:09:58 +08:00
parent f4459c6aac
commit 1108ada1db
2 changed files with 88 additions and 2 deletions

View File

@@ -53,6 +53,21 @@ class OutdoorFairControllerTest
buildCompanyH5Url(request, 12L, 34L));
}
@Test
void companyQrCodeUrlUsesBrowserRefererWhenProxyRewritesHost() throws Exception
{
MockHttpServletRequest request = new MockHttpServletRequest();
request.setScheme("http");
request.setServerName("127.0.0.1");
request.setServerPort(9091);
request.addHeader("Host", "127.0.0.1:9091");
request.addHeader("Referer", "http://39.98.44.136:6024/shihezi/jobfair/outdoor-fair/detail?id=8");
assertEquals(
"http://39.98.44.136:6024/h5/outdoor-fair/company.html?fairId=12&companyId=34",
buildCompanyH5Url(request, 12L, 34L));
}
private String buildCompanyH5Url(MockHttpServletRequest request, Long fairId, Long companyId)
throws Exception
{