Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Confusion between dataURI and dataURL in javascript

Tags:

javascript

What is the difference between data URI and data URL?

Look here. Both of these terms are used, but how are they different?

By the way, this is different from the posts mentioned to be possible duplicates. It's not a HTTP question ! This is javascript.

like image 686
Arian Avatar asked May 26 '17 20:05

Arian


1 Answers

URIs are a superset of URLs. All URLs are URIs, but some URIs are not URLs. This answer has the proper definitions. As you can surmise by reading them, there's a gray area that depends on context.

As for your specific question, getDataUrl() returns an URI. It is not a URL, since it doesn't really include any information regarding how to locate the resource externally. The function is not named appropriately, as the MDN link reflects.

But, this information is implicit: as the data blob lives inside the URI itself, there's only one place where it can be found. So you could argue, as you sip from your tea and adjust your monocle, that it is a URL, since no further clarification about protocol, schema or location is needed.

In other words, this is highly subject to interpretation. I wouldn't pay much mind to it.

like image 173
slezica Avatar answered Oct 12 '22 08:10

slezica