quicksilver/Quicksilver — Issue #625: Should there be a type for search URLs?
Author: skurfer
Created: 2011-12-19 14:00:01+00:00
State: open

I had always kind of assumed there was a type for search URLs, but apparently there isn't. Should we create one?

I can't think of any drawbacks, but there are some benefits.

For one, I see stuff like this all over the code:

```obj-c
NSURL *url = [NSURL URLWithString:[urlString URLEncoding]];
NSString *query = [url absoluteString];
if (query && [query rangeOfString:QUERY_KEY].location != NSNotFound) {
// treat this like a search URL
}
```

Wouldn't it be nicer to just say:

```obj-c
if ([[object primaryType] isEqualToString:QSSearchURLType]) {
// treat this like a search URL
}
```

And there's the special case of getting indirect objects for the “Find with…” action in the Web Search plug-in. Currently, it gets **all** QSObjects with `QSURLType` from the catalog and then does a bunch of processing on them, including the check above. If we could do something like this:

```obj-c
NSArray *searchURLs = [QSLib arrayForType:QSSearchURLType];
```

Not only would the code be a lot simpler, but (I'm assuming) it would execute much faster.

And finally, the thing that led me to this thinking in the first place: proxy objects. I've added a search URL as a proxy object in the Safari plug-in. It works great in the first pane, but when using "Find With…", it never appears in the third pane. If there were an explicit search URL type, I *think* I could get the proxy to show in the third pane.

I can make the necessary changes, I just wanted to get opinions first. By adding a simple check to `assignURLTypesWithURL`, the rest of the application and plug-ins should get the new type “for free”. Then of course I'd have to go update a few places to take advantage of the change.