1717package org .springframework .web .server .support ;
1818
1919import org .springframework .lang .Nullable ;
20- import org .springframework .web .server .ServerWebExchange ;
2120
2221/**
2322 * Lookup path information of an incoming HTTP request.
@@ -32,30 +31,23 @@ public final class LookupPath {
3231
3332 private final String path ;
3433
35- private final int fileExtensionIndex ;
34+ private final int fileExtStartIndex ;
3635
37- private final int pathParametersIndex ;
36+ private final int fileExtEndIndex ;
3837
39- public LookupPath (String path , int fileExtensionIndex , int pathParametersIndex ) {
38+ public LookupPath (String path , int fileExtStartIndex , int fileExtEndIndex ) {
4039 this .path = path ;
41- this .fileExtensionIndex = fileExtensionIndex ;
42- this .pathParametersIndex = pathParametersIndex ;
40+ this .fileExtStartIndex = fileExtStartIndex ;
41+ this .fileExtEndIndex = fileExtEndIndex ;
4342 }
4443
4544 public String getPath () {
46- if (this .pathParametersIndex != -1 ) {
47- // TODO: variant without the path parameter information?
48- //return this.path.substring(0, this.pathParametersIndex);
4945 return this .path ;
50- }
51- else {
52- return this .path ;
53- }
5446 }
5547
5648 public String getPathWithoutExtension () {
57- if (this .fileExtensionIndex != -1 ) {
58- return this .path .substring (0 , this .fileExtensionIndex );
49+ if (this .fileExtStartIndex != -1 ) {
50+ return this .path .substring (0 , this .fileExtStartIndex );
5951 }
6052 else {
6153 return this .path ;
@@ -64,21 +56,15 @@ public String getPathWithoutExtension() {
6456
6557 @ Nullable
6658 public String getFileExtension () {
67- if (this .fileExtensionIndex == -1 ) {
59+ if (this .fileExtStartIndex == -1 ) {
6860 return null ;
6961 }
70- else if (this .pathParametersIndex == -1 ) {
71- return this .path .substring (this .fileExtensionIndex );
62+ else if (this .fileExtEndIndex == -1 ) {
63+ return this .path .substring (this .fileExtStartIndex );
7264 }
7365 else {
74- return this .path .substring (this .fileExtensionIndex , this .pathParametersIndex );
66+ return this .path .substring (this .fileExtStartIndex , this .fileExtEndIndex );
7567 }
7668 }
7769
78- @ Nullable
79- public String getPathParameters () {
80- return this .pathParametersIndex == -1 ?
81- null : this .path .substring (this .pathParametersIndex + 1 );
82- }
83-
8470}
0 commit comments