diff --git a/lib/trim-slash.js b/lib/trim-slash.js
index <HASH>..<HASH> 100644
--- a/lib/trim-slash.js
+++ b/lib/trim-slash.js
@@ -14,12 +14,10 @@
  * @ nosideeffects
  */
 function trimSlash(string) {
-  if (typeof string !== 'string') {
-    return string;
-  }
-  if (string.length > 0 && string.charAt(string.length - 1) === '/') {
-    return string.slice(0, string.length - 1);
+  if (typeof string === 'string' && string.endsWith('/')) {
+    return string.slice(0, -1);
   }
+
   return string;
 }
style: clean up trimSlash

This code violates the ESLint unicorn/prefer-negative-index rule.  Clean
it up and simplify a bit.