MCPcopy Create free account
hub / github.com/MediaArea/MediaInfo / ExtractFileExtensionFromUrl

Function ExtractFileExtensionFromUrl

Source/WindowsShellExtension/dllmain.cpp:231–248  ·  view source on GitHub ↗

Adapted from code generated with Google Gemini 2.0 Flash

Source from the content-addressed store, hash-verified

229
230 // Adapted from code generated with Google Gemini 2.0 Flash
231 std::string ExtractFileExtensionFromUrl(_In_ const std::string& url) {
232 // Find the last '/' before the '?' or end of string
233 size_t lastSlashPos{ url.find_last_of('/') };
234 size_t queryPos{};
235 if (lastSlashPos == std::string::npos)
236 queryPos = url.find('?'); // URLs without slashes
237 else
238 queryPos = url.find('?', lastSlashPos + 1);
239 std::string filename;
240 if (queryPos == std::string::npos)
241 filename = url.substr(lastSlashPos + 1); // URLs without query strings
242 else
243 filename = url.substr(lastSlashPos + 1, queryPos - lastSlashPos - 1);
244
245 // Extract the extension using std::filesystem
246 std::filesystem::path filePath{ filename };
247 return filePath.extension().string();
248 }
249
250 // Function to check for supported file extensions
251 bool IsSupportedFileExtension(_In_ const std::string& extension) {

Callers 1

dllmain.cppFile · 0.85

Calls 1

extensionMethod · 0.80

Tested by

no test coverage detected