fix: ensure_file_path_valid for folder path

This commit is contained in:
debugtalk
2020-06-06 22:25:50 +08:00
parent d29941124d
commit be627549e1
2 changed files with 5 additions and 1 deletions

View File

@@ -198,7 +198,7 @@ def ensure_file_path_valid(file_path: Text) -> Text:
raw_file_relative_name = raw_file_name
path_names = []
for name in raw_file_relative_name.split(os.sep):
for name in raw_file_relative_name.rstrip(os.sep).split(os.sep):
if name[0] in string.digits:
# ensure file name not startswith digit

View File

@@ -126,3 +126,7 @@ class TestUtils(unittest.TestCase):
ensure_file_path_valid("1/2B/3.yml"),
os.path.join(os.getcwd(), "T1/T2B/T3.yml"),
)
self.assertEqual(
ensure_file_path_valid("examples/postman-echo/request.methods/"),
os.path.join(os.getcwd(), "examples/postman_echo/request_methods"),
)