My javascript solution passes all of the tests except for the limit on file extension length.
Should the output for extension > 10 characters be “UNKNOWN” even if the MIME definitions include an extension that is more than 10 characters?
Hello.
I’m fairly sure there is no special behaviour for long extensions, I’m inclined to believe your program fails for another reason.
Just to be sure, do you correctly handle cases where there are only the filename or only the extension ?
For example, this input:
Why is ‘.html’ text/html? If I use python’s os.path.splitext function it is just hidden file “.html” with no extension. I passed the test using split. Please add a note about that.
I have the same problem, my program keep failing the limit size in extensions even it is able to pass all the other tests, even the one that you are providing in this reply.
However the Limit size in extensions test is keep failing.
What is it suppose to happen for something like:
Ok so, as I expected, the tests won’t try to force this constrains by themselves. Is it possible to have the test to debug it?
I find kind of hard the debug something which is failing without knowing the input. I can imagine tons of possible things going wrong: uninitialized variables, weird input data sequence. Stupid stuff but without a bug-trace these are just hypothesis.
The explanation is not clear about what to do with extensions > 10 characters.
What did work for my code and made me jump from 95% to 100% is creating the list of mime types, include EXT but truncate them to the FIRST 10 characters.
When searching the filenames extension also check only the first 10 characters of the filename extension you find.
Example Input:
1
1
verylongextension text/longextensiontext
file.verylongextension
Your code should map
“verylongex” mime-type to “text/longextensiontext”
and check the filename extension “.verylongextension” as “verylongex” thus find the appropriate mime-type.
HTH
This helped me get from 95% to 100%. The explanation is not clear on the problem. I was assigning UNKNOWN by default when the extension was longer than 10 characters.
So, if I understand everything correctly, this means that I should not have the “verylongextension text/longextensiontext” MIME association but “verylongex text/longextensiontext” ?
Thanks demnaty for clarifying that what I wrote 5 years ago ist incorrect although other Coders have confirmed that it helped them. It could be that the puzzle has been corrected since, that idea could cross your mind when comparing 2021 to 2016, especially when others confirmed that it had to be done in the way I described five years ago. It could however also have something to do with the choice of programming language. I might check the puzzle again if I have some spare time to validate that it has been corrected. Thanks for your input.