File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -76,8 +76,16 @@ public function limiter($name)
7676 return $ result ;
7777 }
7878
79+ $ duplicates = collect ($ result )->duplicates ('key ' );
80+
81+ if ($ duplicates ->isEmpty ()) {
82+ return $ result ;
83+ }
84+
7985 foreach ($ result as $ limit ) {
80- $ limit ->key = $ limit ->uniqueKey ();
86+ if ($ duplicates ->contains ($ limit ->key )) {
87+ $ limit ->key = $ limit ->fallbackKey ();
88+ }
8189 }
8290
8391 return $ result ;
Original file line number Diff line number Diff line change @@ -144,16 +144,12 @@ public function response(callable $callback)
144144 }
145145
146146 /**
147- * Retrieve a unique key for the limit.
147+ * Retrieve a fallback key for the limit.
148148 *
149149 * @return string
150150 */
151- public function uniqueKey ()
151+ public function fallbackKey ()
152152 {
153- if ($ this ->key !== '' ) {
154- return $ this ->key ;
155- }
156-
157153 return "attempts: {$ this ->maxAttempts }:decay: {$ this ->decaySeconds }" ;
158154 }
159155}
You can’t perform that action at this time.
0 commit comments