Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
When should I use the `match.path` over `match.url`?
This is in reference to React's React Router DOM library.
Ondrej Salamon1,501 Points
I suppose it depends on an problem you're solving.
I don't know any of React stuff or course your question is related to but generally speaking, url is "complete" address, i.e. string with protocol + domain + path + parameters, anchors etc. whereas path is just a part of url after domain (and "/") and without parameters, anchors etc.
URL: "http://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument" PATH: just "/path/to/myfile.html" (Source: https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL)
So if you want to match something inside your app or on your local server I'd say it is safer to use "path". Because you want to match your local files or paths inside root folder of your local server you don't care about domain, protocol and so.