* If a given URL is relative, return a version of the URL resolved * to the local file scheme; otherwise return a copy of the URL. * * KTextEditor (plugins) can look up or open a document by a relative URL. * DocumentController asserts that a URL passed to it is not relative. This function * assumes that a relative URL points to a local file and works around the assertion failures. * * @pre
| 57 | * @pre @p !url.isEmpty() because an empty URL is special and should be handled separately by the callers |
| 58 | */ |
| 59 | [[nodiscard]] QUrl resolvedToLocalFile(QUrl url) |
| 60 | { |
| 61 | Q_ASSERT(!url.isEmpty()); |
| 62 | if (url.isRelative()) { |
| 63 | url.setScheme(QStringLiteral("file")); |
| 64 | } |
| 65 | return url; |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * @return whether a given URL can possibly point to a file |