Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion micropython/mip/manifest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
metadata(version="0.5.0", description="On-device package installer for network-capable boards")
metadata(version="0.5.1", description="On-device package installer for network-capable boards")

require("requests")

Expand Down
4 changes: 3 additions & 1 deletion micropython/mip/mip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ def _install_json(package_json_url, index, target, version, mpy):
if not _download_file(file_url, fs_target_path):
print("File not found: {} {}".format(target_path, short_hash))
return False
base_url = package_json_url.rpartition("/")[0]
# str.rpartition is not available on all builds.
slash = package_json_url.rfind("/")

@Josverl Josverl Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason not to use package_json_url.split("/",1)[0] ?
That would leave the code simpler and I assume the memory fragmentation is not that much worse

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to split at the last slash. rsplit would work but doesn't offer any benefits over rfind.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rsplit('/')[0] would be better, but it does not work in the case where there are no slashes in the path.

base_url = package_json_url[:slash] if slash >= 0 else ""
for target_path, url in package_json.get("urls", ()):
fs_target_path = target + "/" + target_path
is_full_url = any(url.startswith(p) for p in _ALLOWED_MIP_URL_PREFIXES)
Expand Down
Loading