17
17
package org .springframework .web .server .support ;
18
18
19
19
import org .springframework .lang .Nullable ;
20
- import org .springframework .web .server .ServerWebExchange ;
21
20
22
21
/**
23
22
* Lookup path information of an incoming HTTP request.
@@ -32,30 +31,23 @@ public final class LookupPath {
32
31
33
32
private final String path ;
34
33
35
- private final int fileExtensionIndex ;
34
+ private final int fileExtStartIndex ;
36
35
37
- private final int pathParametersIndex ;
36
+ private final int fileExtEndIndex ;
38
37
39
- public LookupPath (String path , int fileExtensionIndex , int pathParametersIndex ) {
38
+ public LookupPath (String path , int fileExtStartIndex , int fileExtEndIndex ) {
40
39
this .path = path ;
41
- this .fileExtensionIndex = fileExtensionIndex ;
42
- this .pathParametersIndex = pathParametersIndex ;
40
+ this .fileExtStartIndex = fileExtStartIndex ;
41
+ this .fileExtEndIndex = fileExtEndIndex ;
43
42
}
44
43
45
44
public String getPath () {
46
- if (this .pathParametersIndex != -1 ) {
47
- // TODO: variant without the path parameter information?
48
- //return this.path.substring(0, this.pathParametersIndex);
49
45
return this .path ;
50
- }
51
- else {
52
- return this .path ;
53
- }
54
46
}
55
47
56
48
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 );
59
51
}
60
52
else {
61
53
return this .path ;
@@ -64,21 +56,15 @@ public String getPathWithoutExtension() {
64
56
65
57
@ Nullable
66
58
public String getFileExtension () {
67
- if (this .fileExtensionIndex == -1 ) {
59
+ if (this .fileExtStartIndex == -1 ) {
68
60
return null ;
69
61
}
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 );
72
64
}
73
65
else {
74
- return this .path .substring (this .fileExtensionIndex , this .pathParametersIndex );
66
+ return this .path .substring (this .fileExtStartIndex , this .fileExtEndIndex );
75
67
}
76
68
}
77
69
78
- @ Nullable
79
- public String getPathParameters () {
80
- return this .pathParametersIndex == -1 ?
81
- null : this .path .substring (this .pathParametersIndex + 1 );
82
- }
83
-
84
70
}
0 commit comments