Tell you a new trick: You can use the normalize_unix_path() function that we recently committed in order to safely merge paths, because it automatically removes double slashes (which is possible in datastore['WritableDir'] because the user might add an extra '/' at the end).

Reference:
https://github.com/rapid7/metasploit-framework/blob/master/lib/rex/file.rb#L19