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

Retrieve File Size in Android programmatically

I'm looking for a way to read 'PDF' size. so far I have attempted the following approaches: Note: all the permissions are in place and i do have access to the file. 1) using file length path =…
Poorya
  • 1,291
  • 6
  • 27
  • 57
2
votes
0 answers

Android - Proper Way to Share Public Files Between Apps

The Issue In the Nougat+ world of Android, Google is enforcing the content:// Uris over file:// Uris. This makes sense for app-private files, but not for system-wide or public ones. I have a file manager app that naturally needs to share the files…
2
votes
0 answers

Send multiple URIs to Browser (Open HTML files from internal storage by FileProvider)

Preface: I'm using C# with Xamarin, but the workflow is the same. I want to open/display (offline) HTML files (which are linked with other HTML, CSS and JavaScript files) in a browser on Android. This is the index.html:
2
votes
1 answer

Java Restlets - Match arbitrarily long URI path parameter

Using Restlets you can route URIs using a system based on the URI template specification. I want to be able to route URIs which match the following pattern http://www.blah.com/something/...arbitrarily long path.../somethingelse/ So, the following…
user130076
2
votes
2 answers

How to retrieve current application root URL in .net core within a static method?

I am currently using the Request.Scheme and Request.Host to composite Uri object to get AbsoluteUri for my .net core MVC application. Uri location = new Uri($"{Request.Scheme}://{Request.Host}"); string applicationRootURL =…
Xiao Han
  • 1,004
  • 7
  • 16
  • 33
2
votes
2 answers

Conditional URI segment error - Codeigniter

I have sort of a weird problem, so bear with me. I'm using the _remap function to implement an example.com/user/username protocol in my URI and I am using the following code: function _remap() { //URI Segment I am…
Patrick C
  • 739
  • 3
  • 12
  • 25
2
votes
2 answers

How to check if BitmapImage created by Uri is actually an image?

my application receives dragged and dropped links from Internet and tries to create image from supplied link. Code looks like this. if (link.StartsWith("http")) { try { itemImage.Source = new BitmapImage(new Uri(link)); if…
Steve
  • 61
  • 8
2
votes
1 answer

Why null data is returned is it saving or not in internal storage because not working in without sd card phone

Why return null data return is it save or not in internal storage because not working in without sd card phone when I am returning after capture then crash app in redmii phone and this is logcat java.lang.RuntimeException: Failure delivering result…
irfan sam
  • 15
  • 1
  • 7
2
votes
1 answer

SecurityException preventing me from displaying an image by storing it's URI in a SQLIte database

I have a SQLite database containing the URI of images (in device memory) of different products in an inventory. I am not able to retrieve an image URI from the database and set it on a ImageView in an activity because of a SecurityException. How do…
ShashankAC
  • 1,016
  • 11
  • 25
2
votes
2 answers

How to get path of a directory that I choose with Intent and use it as File path?

After a button click, I want to create an Intent for browsing files and selecting a directory. Then I want to store a path for this directory in shared preferences. Later I want to use this path as an argument for a File object, so I can, for…
tomas
  • 376
  • 1
  • 5
  • 17
2
votes
1 answer

Request for IRC URI Scheme for HTML Purifier 4.2.0

Can someone help me to establish using IRC URI Scheme for HTML Purifier 4.2.0? I can't seem to figure out how to configure or which files to modify so that purified html allows for irc:// links. Is it possible I can simply modify configuration…
Miz
  • 21
  • 3
2
votes
1 answer

XSLT: include stylesheets into a main stylesheet

I am writing an XSLT 1.0 stylesheet for a big project and it is becoming massive. I would like to take some parts in separate smaller stylesheets and use them in my "main" stylesheet with xsl:include. All XSLT stylesheets are in the same directory.…
Nikowhy
  • 141
  • 2
  • 10
2
votes
1 answer

system.uri' does not contain a definition for 'parsequerystring'

Following an online guide for building a C# class, and pasting the class code into a new class, the only part that doesn't resolve is this line: canonicalRequest.AppendFormat("{0}\n",…
JamesMatson
  • 2,522
  • 2
  • 37
  • 86
2
votes
3 answers

Node.js same uri but different parameters

I'm doing a simple library API with Node.js and express. To fetch a specific book with ISBN or books within a specific genre, I have the following functions: /api/books/isbn router.get('/:isbn', function (req, res) { var isbn =…
JuliusvM
  • 335
  • 6
  • 16
2
votes
2 answers

How can I use at symbol (@) in url?

For example I meet this url type: http://username:token@example.com/protected/files . I searched on the web for this but I don't find what I expected.
Addy
  • 103
  • 8