unjs / giget

โœจ Download templates and git repositories with pleasure!
MIT License
425 stars 37 forks source link

feat: support cloning from http(s) inputs #129

Closed pi0 closed 7 months ago

pi0 commented 7 months ago

๐Ÿ”— Linked issue

resolves #10

previous works #86, #91 โค๏ธ

โ“ Type of change

๐Ÿ“š Description

This PR adds support for input to using http:// or https:// protocols.

If the path ends with .json or a response content type with HEAD method is application/json or text/plain for the sake of GH raw content (reverted in 194581812008c107b80f359b57bbf36c5e8a66c6), we download JSON as Template info.

Otherwise we try to guess name from URL's last segment (basename) or content-disposition filename header if provided in HEAD response as default name.

The fragment support as proposed in initial issue is not implemented as I think with JSON support now we have enough power to control responses without making inputs more complex but PR welcome if there are valid cases for it.

๐Ÿ“ Checklist