I come across this piece of ruby code :
def link_to(link_text, url, mode=:path_only)
# You should add "!!" at the beginning if you're directing at the Sinatra url
if(url_for(url,mode)[0,2] == "!!")
trimmed_url = url_for(url,mode)[2..-1]
"<a href=#{trimmed_url}> #{link_text}</a>"
else
"<a href=#{url_for(url,mode)}> #{link_text}</a>"
end
end
def url_for url_fragment, mode=:full_url
case mode
when :path_only
#cut for brievity. The rest of the function gets rack params and renders full url (or not)
I have no clue what this line of code does : (url_for(url,mode)[0,2] == "!!")
f(x)while constructs likeifare expressed asif xorif (x)if parentheses are used. The space is a small detail, but it makes it read differently.if, which it is not. Tools like Rubocop can help "lint" your code and find issues like this.