Questions tagged [uri]

A Uniform Resource Identifier (or URI) is a string of characters used to identify a name or resource. URI is legacy terminology. In most cases, the term URL should be used instead.

A Uniform Resource Identifier (or URI) is a string of characters used to identify a name or resource.

Note: The current URL Standard at https://url.spec.whatwg.org/#url-representation supersedes RFC 3986 and dispenses with the use of the term URI, as documented in its Goals section:

Standardize on the term URL. URI and IRI are just confusing. In practice a single algorithm is used for both so keeping them distinct is not helping anyone. URL also easily wins the search result popularity contest.

But the information below documents URI in terms of the legacy RFC 3986 spec.


Structure

A URI can be a Uniform Resource Locator , a Uniform Resource Name , or both.

RFC 3986 defines a URI as composed of the following parts:

    foo://example.com:8042/over/there?name=ferret#nose
    \_/   \______________/\_________/ \_________/ \__/
     |           |            |            |        |
  scheme     authority       path        query   fragment

Then defining relative URIs (Section 5.2), you can omit any of those sections, always starting from the left. In pseudo-code, it looks like this:

 result = ""

  if defined(scheme) then
     append scheme to result;
     append ":" to result;
  endif;

  if defined(authority) then
     append "//" to result;
     append authority to result;
  endif;

  append path to result;

  if defined(query) then
     append "?" to result;
     append query to result;
  endif;

  if defined(fragment) then
     append "#" to result;
     append fragment to result;
  endif;

  return result;

The URI you are describing is a scheme-less relative URI.

Examples

For example, in the following URI:

https://stackoverflow.com/questions/tagged/uri?sort=newest&pagesize=50#questions

... the components are:

  • scheme: https

  • hierarchical part: //stackoverflow.com/questions/tagged/uri

  • query: sort=newest&pagesize=50

  • fragment: questions

The precise syntax of the individual components varies depending on the scheme. Here are some examples:

  • mailto:nobody@example.com?subject=Hello&body=Is%20anybody%20home%3F

  • data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=

  • urn:ietf:rfc:3986

URL

A URL is a URI but is more specific. In addition to identifying a web resource, a URL specifies the means of acting upon or obtaining the representation, specifying both its primary access mechanism and network location.

For example, the URL http://example.org/wiki/Main_Page refers to a resource identified as /wiki/Main_Page whose representation, in the form of HTML and related code, obtainable via HyperText Transfer Protocol (http) from a network host whose domain name is example.org.

URI Reference

A URI reference may take the form of a full URI, or just the scheme-specific portion of one, or even some trailing component thereof – even the empty string. An optional fragment identifier, preceded by #, may be present at the end of a URI reference. The part of the reference before the # indirectly identifies a resource, and the fragment identifier identifies some portion of that resource.

To derive a URI from a URI reference, software converts the URI reference to 'absolute' form by merging it with an absolute 'base' URI according to a fixed algorithm. The system treats the URI reference as relative to the base URI, although in the case of an absolute reference, the base has no relevance. The base URI typically identifies the document containing the URI reference, although this can be overridden by declarations made within the document or as part of an external data transmission protocol. If the base URI includes a fragment identifier, it is ignored during the merging process. If a fragment identifier is present in the URI reference, it is preserved during the merging process.

Web document markup languages frequently use URI references to point to other resources, such as external documents or specific portions of the same logical document.

Uses of URI references in markup languages

  • In HTML, the value of the src attribute of the img element provides a URI reference, as does the value of the href attribute of the a or link element.
  • In XML, the system identifier appearing after the SYSTEM keyword in a DTD is a fragmentless URI reference.
  • In XSLT, the value of the href attribute of the xsl:import element/instruction is a URI reference; likewise the first argument to the document() function.

Examples of absolute URIs

Examples of URI references

6139 questions
2
votes
1 answer

Haskell.Network.URI.outside US-ASCII characters

I have the problem to construct URI to make http request via HTTP library. For example: import Network.URI parseURI "http://мтс.рф" or parseURI "http://maps.googleapis.com/maps/api/geocode/json?address=Титова+42&sensor=false" In both cases i have…
Anton
  • 2,535
  • 2
  • 25
  • 28
2
votes
2 answers

requires android.permission.ACCESS_ALL_DOWNLOADS, or grantUriPermission()

When I'm going select a file from all downloads folder and then getting file path from uri using content provider getting following permission denied issue below Permission Denial: reading com.android.providers.downloads.DownloadProvider uri…
JosephM
  • 2,935
  • 4
  • 18
  • 28
2
votes
1 answer

Java Stunt and URI discovery

I'm working on a live video Java application, and have run into the common problem of NAT traversal - two computers can connect to each other on local network, but not when they're behind NATs. I've done some research and the easiest option to get…
2
votes
1 answer

onActivityResult : android.net.Uri android.content.Intent.getData()' on a null object reference

Its work perfectly when i click image from the camera or back press from camera. Ii also works perfectly when i select an image from the gallery but it occurs error when i back press from the gallery without selecting any image at this line…
Unnati Patadia
  • 662
  • 3
  • 19
  • 39
2
votes
0 answers

MalformedURLException does not care for correctness of URL besides correctness of protocol (scheme) ? Why?

These compile and run without MalformedURLException: new URL("http://example.com/dir1/dir2/page1.html&k>v%k1=>v^!"); new URL("http:////\\example\\.com/dir1/\\@dir2/@&##page1.html&k>v%k1=>v^!"); API for URL(String spec) constructor writes…
Code Complete
  • 3,146
  • 1
  • 15
  • 38
2
votes
1 answer

Uri constructor throws exception for relative path without UriKind

Why is new Uri("temp/file.txt") throwing the following exception UriFormatException: Invalid URI: The format of the URI could not be determined. instead of creating a relative Uri? It doesn't know the format so why do I need to specify the…
t3chb0t
  • 16,340
  • 13
  • 78
  • 118
2
votes
1 answer

Why Uri.TryCreate return TRUE for Uri like mail:foo?

why using method Uri.TryCreate I get BOOL TRUE if the URI is not in Uri.Schema??. Here the Uri.Schema from MSDN: http://msdn.microsoft.com/en-us/library/system.uri.scheme.aspx Try for example a string "mail:foo" it return True and I do not…
GibboK
  • 71,848
  • 143
  • 435
  • 658
2
votes
2 answers

How can I compress a URI image?

I am still pretty new to programming, and I want to import images into my app and show them there. The Problem is, whenever I am adding photos into my app, the app crashes shortly after due to an outOfMemory Error in Java. I need to compress the…
Macario
  • 21
  • 1
  • 2
2
votes
1 answer

C# - QR code link in case of load balancer

I am completely new in this part - I have a QR code on my screen which works for both windows and mobile i.e. you can click on that QR code to open a new window with given page in same browser on window or you can scan the QR code which will open…
omkar patade
  • 1,442
  • 9
  • 34
  • 66
2
votes
3 answers

Get not-URI location

When I do string s = Path.Combine(Folders.Data, fileName); I've got file:\\... (the URI location). How can I get c:\... (the not-URI location)? EDIT: The code for the Folders class is: public static class Folders { public static string App …
Jaime Oro
  • 9,899
  • 8
  • 31
  • 39
2
votes
1 answer

Why does the URI constructor remove part of path from the baseUri argument?

public class Program { public static void Main() { Uri baseUri = new Uri("http://localhost:7777/BasePath/"); Uri uri = new Uri(baseUri, "/controller"); Console.WriteLine(uri); } } Is it the intend behavior to…
Junior Mayhé
  • 16,144
  • 26
  • 115
  • 161
2
votes
1 answer

Are URL.getRef() and URI.getFragment() the same?

Are URL.getRef() and URI.getFragment() the same? If not, how do they differ? When running the following test, the results are the same: String url = "http://c.b.a.com:1234/path?p1=1&p2=2#somewhere"; System.out.println(new…
AlikElzin-kilaka
  • 34,335
  • 35
  • 194
  • 277
2
votes
2 answers

Can't get URI for selecting any file from download folder in MI-Oreo(MI-A2) device in android

I need help in fetching file path of contents that we pick from downloads folder or any other folder through Intent. I am attaching a fileUtil class that I have been using and it works well till Nougat version. But with oreo and that too in some…
Sanjay Bhalani
  • 2,424
  • 18
  • 44
2
votes
2 answers

How to open specific app's specific activity clicking on an external link?

I am developing an android app, in which user must need to login first to use it's features. So as usual user must need to login using provided user credential. But I don't want user always enter username and password again and again, so that I am…
Bajrang Hudda
  • 3,028
  • 1
  • 36
  • 63
2
votes
3 answers

Create an URI for an application

I want to have an URI for my app. For example, if my app's name is "GetIt": getit:// Is there an easy way to create one?
papr
  • 4,717
  • 5
  • 30
  • 38