You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
conststripLeadingSlash=s=>s.indexOf('/')===0 ? s.substring(1) : sconststripEndingSlash=s=>s.indexOf('/')===(s.length-1) ? s.substring(0,s.length-1) : s
The expression s.indexOf("/") returns the first index in the string. That means stripEndingSlash will only strip ending slashes from strings with exactly one slash. A string containing two slashes will return with the trailing slash still in place.
Problem
Note the following code found in /src/index.js
The expression
s.indexOf("/")
returns the first index in the string. That meansstripEndingSlash
will only strip ending slashes from strings with exactly one slash. A string containing two slashes will return with the trailing slash still in place.Example
Consider the following cases:
Suggestion
You could fix this by changing
indexOf
tolastIndexOf
, however, usingcharAt
provides a more readable and performant expression:The text was updated successfully, but these errors were encountered: