Skip to content

Commit d06b617

Browse files
committed
simplify a bit
1 parent 45b7ec8 commit d06b617

File tree

2 files changed

+258
-255
lines changed

2 files changed

+258
-255
lines changed

src/lib/sources/huggingFaceSource.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,12 @@ export function parseHuggingFaceUrl(url: string): HFUrl {
125125
const urlObject = new URL(url)
126126
// ^ throws 'TypeError: URL constructor: {url} is not a valid URL.' if url is not a valid URL
127127

128-
if (urlObject.protocol !== 'https:' && urlObject.protocol !== 'http:') {
129-
throw new Error('url must be a HTTP URL')
130-
}
131-
132128
if (
133-
!['huggingface.co', 'huggingface.co', 'hf.co'].includes(urlObject.host) ||
134-
urlObject.protocol !== 'https:'
129+
urlObject.protocol !== 'https:' ||
130+
![
131+
'huggingface.co', 'huggingface.com', 'hf.co',
132+
// hf.com is not a HF domain
133+
].includes(urlObject.host)
135134
) {
136135
throw new Error('Not a Hugging Face URL')
137136
}

0 commit comments

Comments
 (0)