The function _parse_image_ref is designed to parse a given image hyperlink (href) into its component parts, namely the image identifier, the network location (netloc), and a boolean indicating whether the connection should use SSL (HTTPS).
Task Description:
Function Purpose: Create a function that takes a URL string representing an image href and returns a tuple consisting of the image ID, the netloc portion of the URL, and a boolean value indicating whether the URL uses SSL.
Input: The function should accept a single parameter, image_href, which is expected to be a string URL.
Output: It should return a tuple in the format (image_id, netloc, use_ssl), where:
image_id is derived from the last segment of the URL path,
netloc is the network location parsed from the URL, and
use_ssl is True if the scheme of the URL is https, otherwise False.
Edge Cases to Handle:
The function should raise a ValueError if the input image_href is an invalid URL (i.e., it cannot be parsed properly).
The function should handle URLs with varying structures, such as those with or without a trailing slash, and those that may include query parameters or fragments.
Test cases should consider both HTTP and HTTPS schemes as well as malformed URLs to ensure appropriate error handling.
Note:
The solution should be placed in /app/solution.py
The function must be importable as: from solution import _parse_image_ref