I know I can use
a[href$='.mov']
to check if the href refers to a .mov file.
However, can I generally check if the href attribute refers to a file? So any file with a suffix at the end?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t tell from URL, and also the definition of a file is subjective. Technically,
index.htmlis a file, but probably not a file from the prospective of your question.If you had a list of known file extensions you wanted to select, you could do something like this
Otherwise if you had a server side language, you could follow the links and look for download response headers (look for
Content-Disposition: inline) though this is also probably way too much overhead and a bad idea.I don’t think the look for any link with extension is a good idea to determine if it links to a file. You probably want a whitelist, and check against that.