Skip to content

Is there a way to reliably grab the 'latest' version of a lib directly via a URL? #423

Closed
jannisg opened this Issue Sep 12, 2012 · 8 comments

4 participants

@jannisg
jannisg commented Sep 12, 2012

I'm using Sublime Text 2 and the Nettuts Fetch plugin which can fetch resources via a URL, at the moment trying to get the latest version of Modernizr proves difficult as there doesn't seem to be a single URL that would auto server the 'latest' version of this script…

Currently I'm querying the url: "http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.1/modernizr.min.js" directly but the moment 2.6.2 comes out I will still be referencing 2.6.1.

Is there a better way to grab the "latest" of a given library?

Something like: "http://cdnjs.cloudflare.com/ajax/libs/modernizr/latest/modernizr.min.js" where the latest folder would always contain the most up to date version of that lib would be nice.

Any thoughts on this or a better way for me to do what I'd like to do here?

Thanks for reading.

@thomasdavis
cdnjs member
@jannisg
jannisg commented Sep 12, 2012

Thanks for the reply Thomas.

I've installed the cdnjs package but noticed that it only adds a script tag with the properly set src attribute to the chosen library file.

While this is nice, I would like to access the contents of said script so that I can quickly dump the entire script (not just a link/reference to the script) into a local file.

Look forward to your reply.

@pwnall
pwnall commented Sep 13, 2012

I think this would be very useful. latest might be asking for trouble though. How about supporting URLs like

  • /ajax/libs/library_name/2.6.x - latest 2.6
  • /ajax/libs/library_name/2.x.x - latest 2.x
  • /ajax/libs/library_name/x.x.x - latest

For libraries that use semver, this should work pretty well.

@jannisg
jannisg commented Sep 13, 2012

The latest was more for explaining my point than suggesting that it was the best solution, @pwnall's does seem much nicer though as it would allow the locking of a major version which could be very handy.

@ryankirkman
cdnjs member
@jannisg
jannisg commented Sep 13, 2012

That would be my preferred url syntax too.

Thanks @ryankirkman for looking into this.

@thomasdavis
cdnjs member

@jannisg @ryankirkman because we are running a server for the stats now, we could throw an API on there that could handle this situation.

Would add network request so wouldn't be fantastic for serving files on website.

Or we could throw into the build process a script that copies the latest version into a latest.js file next to package.json...

@thomasdavis
cdnjs member

Closing this issue for more information visit #360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.