Aug 14, 2014, 12:09 PM
Post #2 of 4
One way could be to put a condition around the splice.
Re: [ndhaundiyal] Extra desktop/mobile selector is appearing while browsing
[In reply to]
splice @uri_elements, 1, 0, $model_group unless @uri_elements eq $model_group;
This ensures the splice isn't performed if the second uri element is equal to the model group. A regexp may be more suitable if you need to check against multiple model groups:
splice @uri_elements, 1, 0, $model_group unless @uri_elements =~ /^(mobile|desktop)$/;
Lastly, the condition could be better positioned in your code, but I didn't want to hinder the rejoining of the uri elements / updating the uri, inevitably I am uncertain of your intentions beyond this specific problem.
(This post was edited by Zhris on Aug 14, 2014, 12:23 PM)