File tree Expand file tree Collapse file tree
src/cloudscribe.Web.Localization Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,6 +10,13 @@ namespace cloudscribe.Web.Localization
1010{
1111 public class CultureSegmentRouteConstraint : IRouteConstraint
1212 {
13+ public CultureSegmentRouteConstraint ( bool useSecondSegment = false )
14+ {
15+ _useSecondSegment = useSecondSegment ;
16+ }
17+
18+ private bool _useSecondSegment ;
19+
1320 public bool Match (
1421 HttpContext httpContext ,
1522 IRouter route ,
@@ -45,7 +52,20 @@ private string GetStartingSegment(string requestPath)
4552 if ( ! requestPath . Contains ( "/" ) ) return requestPath ;
4653
4754 var segments = SplitOnCharAndTrim ( requestPath , '/' ) ;
48- return segments . FirstOrDefault ( ) ;
55+ if ( _useSecondSegment )
56+ {
57+ if ( segments . Count > 1 )
58+ {
59+ return segments [ 1 ] ; //second segment
60+ }
61+
62+ return null ;
63+ }
64+ else
65+ {
66+ return segments . FirstOrDefault ( ) ;
67+ }
68+
4969 }
5070
5171 private List < string > SplitOnCharAndTrim ( string s , char c )
Original file line number Diff line number Diff line change 22
33 <PropertyGroup >
44 <Description >more flexible localization for ASP.NET Core</Description >
5- <VersionPrefix >2.0.1 </VersionPrefix >
5+ <VersionPrefix >2.0.2 </VersionPrefix >
66 <Authors >Joe Audette</Authors >
77 <TargetFrameworks >netstandard2.0</TargetFrameworks >
88 <AssemblyName >cloudscribe.Web.Localization</AssemblyName >
You can’t perform that action at this time.
0 commit comments