I have a SharePoint application that uses a URL to access a resource.
code:
return web.GetList(web.ServerRelativeUrl + "/lists/UserSettings"); This works fine when I'm on a subsite, because ServerRelativeUrl will return "/sitename"
However, when this is a root site, ServerRelativeUrl will return "/" instead, leading to a poorly formed URL such as "//lists/UserSettings"
I know this seems like a simple problem (and it is) but is there a best practice for approaching this situation that is consistently safe?