That would definitely work. That could even be tied into a more general
URL API (I think Mozilla might have something similar?). Something like:
var urlObject = chrome.url.parse("cnn.com/story"); // Could throw an
exception if the URL is not valid
var aDomain = urlObject.domain; // "cnn.com"
var aPath = urlObject.path; // "/story"
var bookmarkableURL = urlObject.fullURL; // "http://cnn.com/story"
Colin
Nick Baum wrote:
> Alternatively, could we expose the urlFixerUpper as an extension API?
>
> Then Colin could do
> chrome.bookmarks.create(...chrome.urlFixerUpper(myUrl)...);
>
> Nick
>
> On Wed, Sep 16, 2009 at 5:18 PM, Colin Bleckner <[email protected]
> <mailto:[email protected]>> wrote:
>
> Right now I've hacked together a function that checks to see if
> the URL I'm about to add starts with known protocols and, if it
> doesn't, automatically prepends "http://" to it. This (kind of)
> works, but I'm still discovering that it doesn't handle certain
> protocols like "chrome://" or <awesome new protocol that you guys
> add in Chrome 5.0 that I didn't know existed> and I'm fiddling
> with it more often than I'd like. My options are to either sit
> down and write (or find) a complete URI parser in Javascript or
> use whatever you guys have already built (and are going to keep up
> to date for me!). You can imagine which option I prefer. :)
>
> Colin
>
>
> Aaron Boodman wrote:
>> On Wed, Sep 16, 2009 at 1:06 PM, Erik Kay <[email protected]>
>> <mailto:[email protected]> wrote:
>>
>>> This is a really good idea. Apparently, I'm not running the URL
>>> through our URLFixerUpper class (I'm not making that name up), which
>>> does a bunch of stuff to fix up URLs that someone may have typed in or
>>> copied and pasted in (not just the http:// example you gave).
>>>
>>> I filed http://code.google.com/p/chromium/issues/detail?id=22038 for
>>> this. In the future, feel free to just go ahead and file the bug
>>> directly.
>>>
>> I would have leaned the other way, that our API should be pedantic and
>> require a correct URL. In some cases, passing an incomplete URL is a
>> bug on the developer's part and they would want to know at development
>> time, rather than storing bad data.
>>
>> - a
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Chromium-extensions" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/chromium-extensions?hl=en
-~----------~----~----~----~------~----~------~--~---