mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-06-01 11:34:04 +02:00
Add StringUtils.NullIfEmpty & update existing code to use it
This commit is contained in:
parent
aea77ff909
commit
447697ba45
lib/TweetLib.Core
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using TweetLib.Core.Utils;
|
||||||
|
|
||||||
namespace TweetLib.Core.Features.Twitter{
|
namespace TweetLib.Core.Features.Twitter{
|
||||||
public static class TwitterUrls{
|
public static class TwitterUrls{
|
||||||
@ -22,8 +23,7 @@ public static bool IsTwitterLogin2Factor(string url){
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static string? GetFileNameFromUrl(string url){
|
public static string? GetFileNameFromUrl(string url){
|
||||||
string file = Path.GetFileName(new Uri(url).AbsolutePath);
|
return StringUtils.NullIfEmpty(Path.GetFileName(new Uri(url).AbsolutePath));
|
||||||
return string.IsNullOrEmpty(file) ? null : file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetMediaLink(string url, ImageQuality quality){
|
public static string GetMediaLink(string url, ImageQuality quality){
|
||||||
|
@ -6,6 +6,10 @@ namespace TweetLib.Core.Utils{
|
|||||||
public static class StringUtils{
|
public static class StringUtils{
|
||||||
public static readonly string[] EmptyArray = new string[0];
|
public static readonly string[] EmptyArray = new string[0];
|
||||||
|
|
||||||
|
public static string? NullIfEmpty(string str){
|
||||||
|
return string.IsNullOrEmpty(str) ? null : str;
|
||||||
|
}
|
||||||
|
|
||||||
public static (string before, string after)? SplitInTwo(string str, char search, int startIndex = 0){
|
public static (string before, string after)? SplitInTwo(string str, char search, int startIndex = 0){
|
||||||
int index = str.IndexOf(search, startIndex);
|
int index = str.IndexOf(search, startIndex);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user