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
3 answers

How do you get the first part of a URI in Angular 5?

I have a button on my navbar. When clicked, I want a different behavior depending on which URI the user is currently on. Let's say that I have this URI localhost:8080/entity/{entityId} How can I get entity, the first part of the URI, as a string in…
Wissam Goghrod
  • 327
  • 1
  • 5
  • 15
2
votes
1 answer

What URI can be used to request a default resource?

When creating new resources in my REST API I want to give the user the possibility to request an empty resource that already contains some default values. Since it doesn't have an ID per se I am not entirely sure about a RESTful URI that I could use…
Daff
  • 43,734
  • 9
  • 106
  • 120
2
votes
1 answer

get file path for action GET_CONTENT

I know I am asking the question which is already asked lots of time but I have tried lots of answer from them. I have developed below code for taking pdf files and I have setup PROVIDER perfectly. Intent intent = new…
Android Dev
  • 109
  • 7
2
votes
2 answers

JavaScript or Query library to work with paths/URIs

Could someone suggest a library to work with paths like : /a/b/c.jpg or http://asdf/sdf/fd.jpg I need get directory or just filename string, similar to what the following PHP filesystem functons offers: dirname basename
Janis Veinbergs
  • 6,907
  • 5
  • 48
  • 78
2
votes
1 answer

Ionic - Read file from URI

Users of my application can select and crop images using Ionic Native - Crop. After they have cropped their image, I will have the URI of that image such…
EDJ
  • 843
  • 3
  • 17
  • 37
2
votes
6 answers

Play video with ExoPlayer through a folder in the "assets" folder

I'm trying to play a video with the use of ExoPlayer API and by using the exoplayer library of version : 'com.google.android.exoplayer:exoplayer:2.8.1'. I want to play a video called video.mp4 which is in a folder called folder1 and this folder in…
aman
  • 307
  • 21
  • 48
2
votes
1 answer

Is there a datatype to store a UNC path?

I'm searching for a datatype to store UNC paths in. I already tried using Uri but I always get an UriFormatException telling me Invalid URI: The hostname could not be parsed. The UNC path I'm using is \\.\Dap0 which represents a Data Acquisition…
Pete Hilde
  • 659
  • 1
  • 10
  • 24
2
votes
1 answer

Storing and retrieving a directory Uri to/from SharedPreferences

I am trying to store and retrieve a directory Uri using SharedPreferences but can't get it to work. This is my current code for persisting the directory path after the user chose a directory: @Override public void…
saxum
  • 107
  • 2
  • 10
2
votes
0 answers

converting URI to URL using python

I have a list of printers and I got their URI using pycups. now I need to know their IP addresses and to do that, I need to know their URL. How can I convert those URIs to URLs? for example, I have this URI:…
2
votes
1 answer

How can I get URI from a text file?

I do this to get and show the path of an image, but I would like to know how I could do the same with a text file. val intent = Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI) intent.type =…
Adrian Pang
  • 15
  • 1
  • 4
2
votes
1 answer

Cannot resolve method 'resolve' for URI

I am making a Spring Boot Application to serve images. My createFile method tries to get URI from the POST request but it is unable to resolve the files' name. Down below I am trying to make a POST request for serving images. I have the the…
Alex Smith
  • 463
  • 2
  • 8
  • 17
2
votes
1 answer

Query String to identify a resource

In the HTTP protocol the URI is used to identify a resource, and a query-string indicates extra parameters that, according to msdn The Web server can use those parameters to do extra stuff before returning the resource to the user. My question is…
RuiDTLima
  • 35
  • 1
  • 9
2
votes
2 answers

URI for a custom media-type?

I need to describe in RDF documents that are electronically signed PDFs versus documents that are normal PDFs. The list of IANA media types only contains application/pdf media type. What is the good practice to use a custom URI to identify…
ThomasFrancart
  • 470
  • 3
  • 13
2
votes
1 answer

Error with SPARQL on Rstudio

I'm using the sparql package in Rstudio, to query OMIM through bio2rdf. I have tested my query in yasgui and it works correctly. But from Rstudio he returns the following error: > qde <- SPARQL(endpoint,query) Opening and ending tag mismatch: hr…
DanMed
  • 61
  • 1
  • 4
2
votes
1 answer

URI vs URL in React Native

In react-native one can do: const somePath = 'https://...' or const somePath = 'https://...' From what I understand about web addresses is that URIs are a superset of URLs and…
Siya Mzam
  • 4,655
  • 1
  • 26
  • 44