我使用下面的代码删除http://
和www.
或dev.
从网址:
Uri uri = new Uri(this.Referrer);
if (uri != null )
return uri.GetLeftPart(UriPartial.Authority).Replace("http://dev.", "").Replace("http://www.", "").Replace("http://", "");
else
return null;
我不喜欢说我依靠.Replace()
函数。 我有一个bug相当长的一段时间,直到我意识到this.Referrer
没有足够的子域。
有没有更优雅的方式来做到这一点?