@@ -527,6 +527,8 @@ else if (urlText.startsWith("?"))
527527 p += (_prioritizeAdminPages ? -1 : 1 );
528528 priority = p + random .nextFloat ();
529529
530+ checkControllerRelativeUrl ();
531+
530532 try
531533 {
532534 isVisitableURL ();
@@ -605,6 +607,18 @@ public boolean underCreatedProject()
605607 return _projects .contains (currentProject );
606608 }
607609
610+ private void checkControllerRelativeUrl ()
611+ {
612+ if (_actionId != null && _actionId .isControllerFirstUrl () && WebTestHelper .isUseContainerRelativeUrl ())
613+ {
614+ RuntimeException ex = new RuntimeException ("Found a controller-first URL (%s) on %s" .formatted (getUrlText (), getOrigin ()));
615+ if (TestProperties .isControllerFirstUrlFatal ())
616+ throw ex ;
617+ else
618+ TestLogger .warn (ex .getMessage (), ex );
619+ }
620+ }
621+
608622 public boolean isVisitableURL ()
609623 {
610624 if (StringUtils .isBlank (getRelativeURL ()))
@@ -677,12 +691,14 @@ public static class ControllerActionId
677691 @ NotNull private final String _controller ;
678692 @ NotNull private String _action = "" ;
679693 private final String _containerPath ;
694+ private final boolean _controllerFirstUrl ;
680695
681696 public ControllerActionId (@ NotNull String controller , @ NotNull String action )
682697 {
683698 _controller = controller ;
684699 _action = action ;
685700 _containerPath = null ;
701+ _controllerFirstUrl = false ;
686702 }
687703
688704 public ControllerActionId (@ NotNull String url )
@@ -691,6 +707,7 @@ public ControllerActionId(@NotNull String url)
691707
692708 if (rootRelativeURL .startsWith ("_webdav/" ))
693709 {
710+ _controllerFirstUrl = false ;
694711 _controller = "_webdav" ;
695712 String path = EscapeUtil .decode (rootRelativeURL .substring ("_webdav/" .length ()));
696713 if (path .startsWith ("@" ))
@@ -711,6 +728,7 @@ public ControllerActionId(@NotNull String url)
711728 }
712729 if (rootRelativeURL .startsWith ("_webfiles/" ))
713730 {
731+ _controllerFirstUrl = false ;
714732 _controller = "_webfiles" ;
715733 _containerPath = EscapeUtil .decode (rootRelativeURL .substring ("_webfiles/" .length ()));
716734 return ;
@@ -735,6 +753,7 @@ public ControllerActionId(@NotNull String url)
735753 int dash = _action .lastIndexOf ("-" );
736754 _controller = _action .substring (0 ,dash );
737755 _action = _action .substring (dash +1 );
756+ _controllerFirstUrl = false ;
738757 }
739758 else
740759 {
@@ -744,6 +763,7 @@ public ControllerActionId(@NotNull String url)
744763 throw new IllegalArgumentException ("Unable to parse folder out of relative URL: \" " + rootRelativeURL + "\" " );
745764 _controller = rootRelativeURL .substring (0 , postControllerSlashIdx );
746765 rootRelativeURL = rootRelativeURL .substring (postControllerSlashIdx +1 );
766+ _controllerFirstUrl = true ;
747767 }
748768 _containerPath = EscapeUtil .decode (StringUtils .strip (rootRelativeURL , "/" ));
749769 }
@@ -768,6 +788,14 @@ public String getContainerPath()
768788 return _containerPath ;
769789 }
770790
791+ /**
792+ * Allows us to track down pages that still create controller-first URLs
793+ */
794+ public boolean isControllerFirstUrl ()
795+ {
796+ return _controllerFirstUrl ;
797+ }
798+
771799 @ Override
772800 public String toString ()
773801 {
0 commit comments