All Projects → jean-lourenco → UrlCombine

jean-lourenco / UrlCombine

Licence: MIT License
C# util for combining Url paths. Works similarly to Path.Combine.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to UrlCombine

Uri.js
Javascript URL mutation library
Stars: ✭ 6,119 (+26504.35%)
Mutual labels:  url, uri
Scala Uri
Simple scala library for building and parsing URIs
Stars: ✭ 225 (+878.26%)
Mutual labels:  url, uri
Bidi
Bidirectional URI routing
Stars: ✭ 941 (+3991.3%)
Mutual labels:  url, uri
ocaml-uri
RFC3986 URI parsing library for OCaml
Stars: ✭ 85 (+269.57%)
Mutual labels:  url, uri
url-normalize
URL normalization for Python
Stars: ✭ 82 (+256.52%)
Mutual labels:  url, uri
Uri Parser
RFC3986/RFC3987 compliant URI parser
Stars: ✭ 342 (+1386.96%)
Mutual labels:  url, uri
Vscode Remote Workspace
Multi protocol support for handling remote files like local ones in Visual Studio Code.
Stars: ✭ 197 (+756.52%)
Mutual labels:  url, uri
Searchwithmybrowser
Open Cortana searches with your default browser.
Stars: ✭ 285 (+1139.13%)
Mutual labels:  url, uri
ST-OpenUri
The ultimate Sublime Text plugin for opening URIs (URLs) in your file.
Stars: ✭ 25 (+8.7%)
Mutual labels:  url, uri
Uri Components
League URI components objects
Stars: ✭ 244 (+960.87%)
Mutual labels:  url, uri
Uri
🌏 Functions for making sense out of URIs in PHP
Stars: ✭ 259 (+1026.09%)
Mutual labels:  url, uri
Linkt
A lightweight and simple Kotlin library for deep link handling on Android 🔗.
Stars: ✭ 101 (+339.13%)
Mutual labels:  url, uri
Tldts
JavaScript Library to work against complex domain names, subdomains and URIs.
Stars: ✭ 151 (+556.52%)
Mutual labels:  url, uri
Pguri
uri type for PostgreSQL
Stars: ✭ 235 (+921.74%)
Mutual labels:  url, uri
uri
A type to represent, query, and manipulate a Uniform Resource Identifier.
Stars: ✭ 16 (-30.43%)
Mutual labels:  url, uri
uri-query-parser
a parser and a builder to work with URI query string the right way in PHP
Stars: ✭ 38 (+65.22%)
Mutual labels:  url, uri
Chat
A basic SwiftUI chat app that leverages the new URLSessionWebSocketTask.
Stars: ✭ 22 (-4.35%)
Mutual labels:  combine
reachable-urls
Check URLs are reachable in text 🕵️
Stars: ✭ 29 (+26.09%)
Mutual labels:  url
Limg
An image hosting service powered by Laravel
Stars: ✭ 41 (+78.26%)
Mutual labels:  url
urlshortener-rs
A very-very simple url shortener for Rust
Stars: ✭ 34 (+47.83%)
Mutual labels:  url

UrlCombine Build Status

The UrlCombine is a Nuget Package to conveniently combine your base Url and relative url. This library treats the slashes between the base and relative paths to ensure a valid url.

  using UrlCombineLib;

There are 3 ways to use the library:

Static Method

The static method is used with UrlCombine helper class. It doesn't matter if the baseUrl and relativePath end/start with a slash or not, The Combine() method takes care of that:

  var fullUrl = UrlCombine.Combine("www.foo.com.br/", "/bar/zeta");
  // fullUrl = "www.foo.com.br/bar/zeta"

String Extension

The string extesion is used with the CombineUrl method:

  var fullUrl = "www.foo.com.br/".CombineUrl("/bar/zeta");
  // fullUrl = "www.foo.com.br/bar/zeta"

Uri Extension

The Uri extension is used with the Combine method:

  var fullUrl = new Uri("www.foo.com.br/").Combine("/bar/zeta");
  // fullUrl = new Uri("www.foo.com.br/bar/zeta")

Multiple relative paths in runtime

There's also a UrlCombine.Combine overload (alongside Uri and String extension methods) that takes a param string[] as input:

  var fullUrl = new Uri("www.foo.com.br/").Combine("bar", "zeta");
  // fullUrl = new Uri("www.foo.com.br/bar/zeta")

Why not Uri(Uri base, string relative)?

Well, It does more than just validate the slashes. It strips the relative path of the base Uri if it doesn't end with a slash and if the relative path doesn't start with one:

  var uriBase = new Uri("http://www.foo.com/relative");
  var relative = "/other/url";
  
  var uri = new Uri(uriBase, relative);
  // uri.ToString() = "http://www.foo.com/other/url"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].