Personally it won't even occur to me to need borrowing here. I'd add some sugar and convert that into:
url.pathComponents[insertAt: 1] = prefix // or
url.pathComponents[1, insert: true] = prefix
(here "1" is a short version of path.index(after: path.startIndex)
, and insertAt
is a simple variant of a subscript that inserts instead of replacing.