Languages
[Edit]
EN

JavaScript - get file path from URL

7 points
Created by:
Nathanial-Donald
584

In this short article, we would like to show how to get a file path from URL in JavaScript.

Practical example:

Note: the solution returns in the paths ? and # parts too (search and hash parts).

 

Alternative solution

Edit

This solution works only with URLs that are described in the standard (link here).

Warning: URL class is supported major web browsers since 2014-2016.

 

See also

Edit
  1. JavaScript - get file name from path or URL (works in Web Browser)

References

Edit
  1. URL - Wikipedia
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join