Skip to content

Commit d87b30d

Browse files
committed
COLDBOX-1361 #resolve
Routing service was not evaluating the coldbox web mapping when public facing app is in another folder than the coldbox app
1 parent 64fb847 commit d87b30d

File tree

4 files changed

+22
-30
lines changed

4 files changed

+22
-30
lines changed

system/web/routing/Router.cfc

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,21 @@ component
2222
****************************************************************/
2323

2424
property
25-
name ="cachebox"
25+
name ="cachebox"
2626
inject ="cachebox"
2727
delegate="getCache";
28+
2829
property
2930
name ="controller"
30-
inject ="coldbox"
31+
inject ="coldbox"
3132
delegate="relocate,runEvent,runRoute";
33+
3234
property name="flash" inject="coldbox:flash";
35+
3336
property name="logBox" inject="logbox";
37+
3438
property name="log" inject="logbox:logger:{this}";
39+
3540
property
3641
name ="wirebox"
3742
inject ="wirebox"
@@ -101,15 +106,6 @@ component
101106
*/
102107
property name="baseURL" type="string";
103108

104-
/**
105-
* This flag denotes if full URL rewrites are enabled or not. Meaning if the `index` is in the path of the rewriter or not.
106-
* The default value is **false**.
107-
*/
108-
property
109-
name ="fullRewrites"
110-
type ="boolean"
111-
default="false";
112-
113109
/**
114110
* This flag denotes that the routing service will discover the incoming base URL from the host + ssl + environment.
115111
* If off, then it will use whatever the base URL was set in the router.
@@ -174,8 +170,7 @@ component
174170
variables.validExtensions = variables.VALID_EXTENSIONS;
175171
// Initialize the base URL as empty in case the user overrides it in their own router.
176172
variables.baseUrl = "";
177-
// Are full rewrites enabled
178-
variables.fullRewrites = false;
173+
// Multi domain discovery on by default
179174
variables.multiDomainDiscovery = true;
180175

181176
return this;
@@ -201,11 +196,6 @@ component
201196
variables.baseUrl = composeRoutingUrl();
202197
}
203198

204-
// Check if rewrites turned off. If so, append the `index` to it.
205-
if ( !variables.fullRewrites AND !findNoCase( frontController, variables.baseURL ) ) {
206-
variables.baseURL &= "/#frontController#";
207-
}
208-
209199
// Remove any double slashes: sometimes proxies can interfere
210200
variables.baseURL = reReplace( variables.baseURL, "\/\/$", "/", "all" );
211201

@@ -1964,9 +1954,7 @@ component
19641954
* Composes the base routing path with no host or protocol
19651955
*/
19661956
string function composeRoutingPath(){
1967-
var base = findNoCase( ".bx", cgi.script_name ) ? "index.bxm" : "index.cfm";
1968-
return variables.controller.getSetting( "RoutingAppMapping" ) & // routing app mapping
1969-
( variables.fullRewrites ? "" : base ); // full or controller routing
1957+
return variables.controller.getSetting( "RoutingAppMapping" );
19701958
}
19711959

19721960
/*****************************************************************************************/

system/web/services/RoutingService.cfc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,26 @@ component extends="coldbox.system.web.services.BaseService" accessors="true" {
3939
variables.requestService = controller.getRequestService();
4040
variables.wirebox = controller.getWireBox();
4141

42-
// Routing AppMapping Determinations
42+
// Routing AppMapping Determinations according to where the ColdBox app and the Web assets are located.
4343
variables.appMapping = controller.getSetting( "AppMapping" );
44-
variables.routingAppMapping = ( len( variables.appMapping ) ? variables.appMapping & "/" : "" );
44+
variables.webMapping = controller.getSetting( "WebMapping" );
45+
46+
// Determine the routing app mapping
47+
// This is determined by the following process:
48+
// - If the web mapping is empty, then the app mapping is used
49+
// - If the web mapping is not empty, then it is used instead
50+
if ( len( variables.webMapping ) ) {
51+
variables.routingAppMapping = variables.webMapping;
52+
} else {
53+
variables.routingAppMapping = ( len( variables.appMapping ) ? variables.appMapping & "/" : "" );
54+
}
4555
// Make sure it's prefixed with /
4656
variables.routingAppMapping = left( variables.routingAppMapping, 1 ) == "/" ? variables.routingAppMapping : "/#variables.routingAppMapping#";
47-
4857
// Store routing appmapping
4958
controller.setSetting( "routingAppMapping", variables.routingAppMapping );
5059

5160
// Register as an interceptor to listen to pre processes for routing
52-
variables.controller.getInterceptorService().registerInterceptor( interceptorObject = this );
61+
variables.controller.getInterceptorService().registerInterceptor( interceptorObject : this );
5362

5463
// Load the Application Router
5564
loadRouter();

test-harness/config/Router.cfc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
component {
22

33
function configure(){
4-
// setFullRewrites( false );
5-
64
route( "/bar" ).toModuleRouting( "resourcesTest" );
75

86
// Nested Resources

tests/suites/loadtests/beload/config/Router.cfc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
component {
22

33
function configure() {
4-
// Set Full Rewrites
5-
setFullRewrites( true );
6-
74
/**
85
* --------------------------------------------------------------------------
96
* App Routes

0 commit comments

Comments
 (0)