@@ -61,7 +61,7 @@ public static function getStatuses(): array
61
61
*/
62
62
public function scopeWhereOldUrl (Builder $ query , string $ url ): Builder
63
63
{
64
- return $ query ->where ('old_url ' , $ url );
64
+ return $ query ->where ('old_url ' , config ( ' redirection.case-sensitive ' ) ? $ url : strtolower ( $ url ) );
65
65
}
66
66
67
67
/**
@@ -74,7 +74,7 @@ public function scopeWhereOldUrl(Builder $query, string $url): Builder
74
74
*/
75
75
public function scopeWhereNewUrl (Builder $ query , string $ url ): Builder
76
76
{
77
- return $ query ->where ('new_url ' , $ url );
77
+ return $ query ->where ('new_url ' , config ( ' redirection.case-sensitive ' ) ? $ url : strtolower ( $ url ) );
78
78
}
79
79
80
80
/**
@@ -85,7 +85,8 @@ public function scopeWhereNewUrl(Builder $query, string $url): Builder
85
85
*/
86
86
public function setOldUrlAttribute (string $ value ): void
87
87
{
88
- $ this ->attributes ['old_url ' ] = trim (parse_url ($ value )['path ' ], '/ ' );
88
+ $ value = trim (parse_url ($ value )['path ' ], '/ ' );
89
+ $ this ->attributes ['old_url ' ] = config ('redirection.case-sensitive ' ) ? $ value : strtolower ($ value );
89
90
}
90
91
91
92
/**
@@ -96,7 +97,8 @@ public function setOldUrlAttribute(string $value): void
96
97
*/
97
98
public function setNewUrlAttribute (string $ value ): void
98
99
{
99
- $ this ->attributes ['new_url ' ] = trim (parse_url ($ value )['path ' ], '/ ' );
100
+ $ value = trim (parse_url ($ value )['path ' ], '/ ' );
101
+ $ this ->attributes ['new_url ' ] = config ('redirection.case-sensitive ' ) ? $ value : strtolower ($ value );
100
102
}
101
103
102
104
/**
@@ -127,7 +129,9 @@ public function syncOldRedirects(RedirectionModelContract $model, string $finalU
127
129
*/
128
130
public static function findValidOrNull (string $ path ): ?Redirection
129
131
{
130
- return static ::where ('old_url ' , $ path === '/ ' ? $ path : trim ($ path , '/ ' ))
132
+ $ path = ($ path === '/ ' ? $ path : trim ($ path , '/ ' ));
133
+
134
+ return static ::where ('old_url ' , config ('redirection.case-sensitive ' ) ? $ path : strtolower ($ path ))
131
135
->whereNotNull ('new_url ' )
132
136
->whereIn ('status_code ' , array_keys (self ::getStatuses ()))
133
137
->latest ()
0 commit comments