Conversation
TimeDescription: Provides the local time of country, city or state searched Example Query: [time in Melbourne](https://beta.duckduckgo.com/?q=time in Melbourne), [what time is it in Melbourne](https://beta.duckduckgo.com/?q=what time is it in Melbourne), [what is the time in Birmingham](https://beta.duckduckgo.com/?q=what is the time in Birmingham), [time for Australia](https://beta.duckduckgo.com/?q=time for Australia) Tab Name: Time Source: These are the important fields from the IA page. Please check these for errors or missing information and update the IA page This is an automated message which will be updated as changes are made to the IA page |
var script = $('[src*="/js/spice/time/"]')[0], | ||
source = $(script).attr("src"), | ||
// Query is normalized as we'll normalize the generated strings. | ||
// if we have a comma separated query it is in the form: | ||
// "town, state, country" but state is optional | ||
query = decodeURIComponent(source.match(/time\/([^\/]+)/)[1]).toLowerCase().split(','), | ||
isGeneric = /\/generic\//.test(source), | ||
callParameters = decodeURIComponent(source).split('/'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use decodeURIComponentSafe(source)
here to avoid page crashing errors?
@bsstoner all done. |
@nilnilnil Have tested, looks good to me. Any reason you also check the length of I'll hand this to @moollaza to merge 👍 🎄 |
I added a comment. Is it confusing? I'm happy to revise. I check it because I don't want to assume everything will be defined properly. It's probably a safe bet though. Didn't see a reason to risk it. |
@nilnilnil Nah it's fine! Makes sense to check the array items exist before using them. 👍 Merry Christmas |
Automated screenshot from [beta.duckduckgo.com](https://beta.duckduckgo.com/?q=time in Melbourne) |
Time: Improve Generic Time handling
@MrChrisW @moollaza @bsstoner
@bsstoner I could probably use some JS cleanup :)
IA Page: https://duck.co/ia/view/time