Permalink
Browse files

Fixes #69 and #98 by correcting buildURL() handling of ?, ?? and # - …

…also added a fairly comprehensive visual testbed to show what is possible.
  • Loading branch information...
1 parent 41edb03 commit 216d6efa2bf5e4404bb835bac9342ec7c8b5b570 @seancorfield committed Oct 16, 2011
@@ -0,0 +1,3 @@
+component extends="org.corfield.framework" {
+ variables.framework = { generateSES = true };
+}
No changes.
@@ -0,0 +1,17 @@
+<cfoutput>
+ <h1>Testbed for buildURL()</h1>
+ <p><a href="#buildURL('main.default')#">buildURL('main.default')</a></p>
+ <p><a href="#buildURL('main.default##anchor')#">buildURL('main.default##anchor')</a></p>
+ <p><a href="#buildURL('main.default?##anchor')#">buildURL('main.default?##anchor')</a></p>
+ <p><a href="#buildURL('main.default??##anchor')#">buildURL('main.default??##anchor')</a></p>
+ <p><a href="#buildURL('main.default?test=1')#">buildURL('main.default?test=1')</a></p>
+ <p><a href="#buildURL('main.default?test=1##anchor')#">buildURL('main.default?test=1##anchor')</a></p>
+ <p><a href="#buildURL('main.default??test=2')#">buildURL('main.default??test=2')</a></p>
+ <p><a href="#buildURL('main.default??test=2##anchor')#">buildURL('main.default??test=2##anchor')</a></p>
+ <p><a href="#buildURL(action='main.default',queryString='##anchor')#">buildURL(action='main.default',queryString='##anchor')</a></p>
+ <p><a href="#buildURL(action='main.default',queryString='?##anchor')#">buildURL(action='main.default',queryString='?##anchor')</a></p>
+ <p><a href="#buildURL(action='main.default',queryString='test=1')#">buildURL(action='main.default',queryString='test=1')</a></p>
+ <p><a href="#buildURL(action='main.default',queryString='test=1##anchor')#">buildURL(action='main.default',queryString='test=1##anchor')</a></p>
+ <p><a href="#buildURL(action='main.default',queryString='?test=2')#">buildURL(action='main.default',queryString='?test=2')</a></p>
+ <p><a href="#buildURL(action='main.default',queryString='?test=2##anchor')#">buildURL(action='main.default',queryString='?test=2##anchor')</a></p>
+</cfoutput>
View
@@ -87,10 +87,25 @@ component {
omitIndex = true;
}
}
-
- if ( find( '?', action ) && queryString == '' ) {
- queryString = listRest( action, '?' );
- action = listFirst( action, '?##' );
+ if ( queryString == '' ) {
+ // extract query string from action section:
+ var q = find( '?', action );
+ var a = find( '##', action );
+ if ( q > 0 ) {
+ queryString = right( action, len( action ) - q );
+ if ( q == 1 ) {
+ action = '';
+ } else {
+ action = left( action, q - 1 );
+ }
+ } else if ( a > 0 ) {
+ queryString = right( action, len( action ) - a + 1 );
+ if ( a == 1 ) {
+ action = '';
+ } else {
+ action = left( action, a - 1 );
+ }
+ }
}
var cosmeticAction = getFullyQualifiedAction( action );
var isHomeAction = cosmeticAction == getFullyQualifiedAction( variables.framework.home );
@@ -127,12 +142,33 @@ component {
}
if ( len( queryString ) ) {
- extraArgs = listFirst( queryString, '?##' );
- if ( find( '?', queryString ) ) {
- queryPart = listRest( queryString, '?' );
- }
- if ( find( '##', queryString ) ) {
- anchor = listRest( queryString, '##' );
+ // extract query part and anchor from query string:
+ q = find( '?', queryString );
+ if ( q > 0 ) {
+ queryPart = right( queryString, len( queryString ) - q );
+ if ( q > 1 ) {
+ extraArgs = left( queryString, q - 1 );
+ }
+ a = find( '##', queryPart );
+ if ( a > 0 ) {
+ anchor = right( queryPart, len( queryPart ) - a );
+ if ( a == 1 ) {
+ queryPart = '';
+ } else {
+ queryPart = left( queryPart, a - 1 );
+ }
+ }
+ } else {
+ extraArgs = queryString;
+ a = find( '##', extraArgs );
+ if ( a > 0 ) {
+ anchor = right( extraArgs, len( extraArgs ) - a );
+ if ( a == 1 ) {
+ extraArgs = '';
+ } else {
+ extraArgs = left( extraArgs, a - 1 );
+ }
+ }
}
if ( ses ) {
extraArgs = listChangeDelims( extraArgs, '/', '&=' );
@@ -1641,7 +1677,7 @@ component {
if ( !structKeyExists( variables.framework, 'subsystems' ) ) {
variables.framework.subsystems = { };
}
- variables.framework.version = '2.0_RC';
+ variables.framework.version = '2.0_RC1';
}
private void function setupRequestDefaults() {

0 comments on commit 216d6ef

Please sign in to comment.