Fix for exception throw when validating URLs (#7701)
This commit is contained in:
@@ -79,6 +79,21 @@ namespace Umbraco.Core
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the extension of the path or URL
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <returns>Extension of the file</returns>
|
||||
public static string GetFileExtension(this string file)
|
||||
{
|
||||
//Find any characters between the last . and the start of a query string or the end of the string
|
||||
const string pattern = @"(?<extension>\.[^\.\?]+)(\?.*|$)";
|
||||
var match = Regex.Match(file, pattern);
|
||||
return match.Success
|
||||
? match.Groups["extension"].Value
|
||||
: string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Based on the input string, this will detect if the string is a JS path or a JS snippet.
|
||||
/// If a path cannot be determined, then it is assumed to be a snippet the original text is returned
|
||||
|
||||
Reference in New Issue
Block a user