@@ -8,3 +8,14 @@ export const sanitizeHTML = ( unsafeHTML, domPurifyConfig = {} ) => {
 		__html: purify.sanitize( unsafeHTML, domPurifyConfig ),
 	};
 };
+
+/**
+ * Takes a string, removes the trailing stash if any and returns it.
+ *
+ * @since n.e.x.t
+ * @private
+ *
+ * @param {string} string A string with or without trailing slash.
+ * @return {string|null} The string after removing the trailing slash.
+ */
+export const unTrailingSlashIt = ( string ) => string?.replace?.( /\/+$/, '' );
/**
 * Internal dependencies
 */
import { purify } from './purify';

export const sanitizeHTML = ( unsafeHTML, domPurifyConfig = {} ) => {
	return {
		__html: purify.sanitize( unsafeHTML, domPurifyConfig ),
	};
};

I think it would make sense to rename this to `untrailingslashit`. It's a familiar function name for WordPress developers and using a different style of naming here makes it a bit confusing. Alternatively, we could use a completely different name like `removeTrailingSlash`, but I think since we're in WordPress, using that "familiar" name makes sense.