-
Notifications
You must be signed in to change notification settings - Fork 141
Closed
Labels
🐛 bugSomething isn't workingSomething isn't working
Description
🐛 Bug description (make it clear to everyone)
The code uses rstrip("api")
to drop a trailing "/api"
from a base URL/host.
But rstrip
treats its argument as a set of characters ({'a','p','i'}
) and strips all trailing occurrences of those chars.
This mutilates valid hosts/paths.
Example:
"www.example.ai".rstrip("api") # -> "www.example."
🧑💻 Steps to reproduce
- Set a host/base URL ending with
.ai
(or anything ending ina
,p
, ori
), e.g.:base = "https://www.example.ai/api"
- Run the logic that normalizes/removes the
"/api"
suffix (e.g., login/init flow). - Observe the resulting host string becomes:
(the trailing
https://www.example.
ai
is incorrectly stripped)
👾 Expected result
- Remove the suffix only if the string ends with the exact
"/api"
once. - Do not strip characters from legitimate domain endings such as
.ai
,.app
, etc.
Examples:
"https://www.example.ai/api"
→"https://www.example.ai"
"https://www.example.ai"
→ unchanged
🚑 Any additional info (screenshots, code, logs)
Minimal proof:
>>> "www.example.ai".rstrip("api")
'www.example.'
>>> "https://www.example.ai/api".rstrip("api")
'https://www.example.'
🔧 Suggested fix
🧭 Environment
- SwanLab Version: v0.6.7
- Platform/OS: Ubuntu 22.04
- Python Version: 3.10.12
Reported by Kingdee Cloud Team 💼
Metadata
Metadata
Assignees
Labels
🐛 bugSomething isn't workingSomething isn't working