diff --git a/Apewer/NetworkUtility.cs b/Apewer/NetworkUtility.cs
index 5832e55..8478440 100644
--- a/Apewer/NetworkUtility.cs
+++ b/Apewer/NetworkUtility.cs
@@ -1,19 +1,16 @@
using Apewer.Network;
using System;
-using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
-using System.Runtime.InteropServices;
-using System.Text;
namespace Apewer
{
///
- public class NetworkUtility
+ public static class NetworkUtility
{
#region UDP
@@ -567,6 +564,33 @@ namespace Apewer
#endregion
+ #region URI
+
+ /// 获取路径片段。
+ /// URI
+ /// Segmentals 的索引。索引 0 的位置为空(HOST 部分)。
+ /// 解码 URL。
+ public static string Segmental(this Uri uri, int index, bool decode = false)
+ {
+ if (uri == null) return null;
+ return Segmental(uri.Segments, index, decode);
+ }
+
+ /// 获取路径片段。
+ /// 片段集合。
+ /// Segmentals 的索引。索引 0 的位置为空(HOST 部分)。
+ /// 解码 URL。
+ internal static string Segmental(string[] segmentals, int index, bool decode = false)
+ {
+ if (segmentals == null || segmentals.Length < 1) return null;
+ if (index < 1 || index >= segmentals.Length) return null;
+ var segmental = segmentals[index];
+ if (decode) segmental = TextUtility.DecodeUrl(segmental);
+ return segmental;
+ }
+
+ #endregion
+
}
}