I need to implement functions to check whether paths and urls are relative, absolute, or invalid (invalid syntactically- not whether resource exists). What are the range of cases I should be looking for?
function check_path($dirOrFile) {
// If it's an absolute path: (Anything that starts with a '/'?)
return 'absolute';
// If it's a relative path:
return 'relative';
// If it's an invalid path:
return 'invalid';
}
function check_url($url) {
// If it's an absolute url: (Anything that starts with a 'http://' or 'https://'?)
return 'absolute';
// If it's a relative url:
return 'relative';
// If it's an invalid url:
return 'invalid';
}
<ocd>
You forgot closing single-quote in thereturn
values.</ocd>
– Lavernalaverne