Changeset 35266 for main/trunk/greenstone3/src/java
- Timestamp:
- 2021-08-09T13:42:09+12:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java
r34479 r35266 462 462 String requestedURL = request.getRequestURL().toString(); 463 463 String baseURL = ""; 464 //logger.error("requested URL = "+requestedURL); 464 465 if (requestedURL.indexOf(library_name) != -1) 465 466 { 466 baseURL = requestedURL.substring(0, requestedURL.lastIndexOf(library_name)); 467 468 int protocol_boundary_pos = baseURL.indexOf("://"); 469 if (protocol_boundary_pos>=1) { 470 baseURL = baseURL.substring(protocol_boundary_pos+1); // change things like http:// or https:// to // 471 } 467 // we need to work out the baseURL and set it 468 baseURL = requestedURL; 469 int protocol_boundary_pos = baseURL.indexOf("://"); 470 if (protocol_boundary_pos>=1) { 471 baseURL = baseURL.substring(protocol_boundary_pos+1); // change things like http:// or https:// to // 472 } 473 // The baseURL is everything up to the library_name. 474 // eg https://community.greenstone.org/greenstone3/library/collection/twso/page/about 475 // baseURL is //community.greenstone.org/greenstone3 476 // Issues: the library_name may occur in more than one place - eg if its part of the domain name mylibrary.heritage.nz/greenstone3/library 477 // or if a collection name is the same as the library name eg localhost:8585/greenstone3/twso/collection/twso/page/about. 478 // So can't just use teh first or last occurrence. Look for /library-name, and check its not the first position (eg //library.nzdl.org/greenstone3/library) 479 int library_name_index = baseURL.indexOf("/"+library_name); 480 if (library_name_index == 1) { 481 // we have library name at the start of the url - need to use the second one 482 library_name_index = baseURL.indexOf("/"+library_name, 2); 483 } 484 baseURL = baseURL.substring(0, library_name_index+1); 485 //logger.error("new base url = "+baseURL); 472 486 473 487 } 488 474 489 String fullURL; 475 490 if (request.getQueryString() != null)
Note:
See TracChangeset
for help on using the changeset viewer.