@@ -264,20 +264,11 @@ def get_build_slug(self):
264264 return f"zenodo-{ self .record_id } "
265265
266266
267- def get_hashed_slug (url , changes_with_content ):
268- """Return a unique slug that is invariant to query parameters in the url"""
269- parsed_url = urlparse (url )
270- stripped_url = urlunparse (
271- (parsed_url .scheme , parsed_url .netloc , parsed_url .path , "" , "" , "" )
272- )
273-
274- return "meca-" + md5 (f"{ stripped_url } -{ changes_with_content } " .encode ()).hexdigest ()
275-
276267class MecaRepoProvider (RepoProvider ):
277268 """BinderHub Provider that can handle the contents of a MECA bundle
278269
279270 Users must provide a spec consisting of a public URL to the bundle
280- The URL origin must conform to the origin trait when that is set
271+ The URL origin must be included in the list of allowed_origins when that trait is set
281272 """
282273
283274 name = Unicode ("MECA Bundle" )
@@ -328,6 +319,14 @@ def __init__(self, *args, **kwargs):
328319 self .log .info (f"MECA Bundle URL: { self .url } " )
329320 self .log .info (f"MECA Bundle raw spec: { self .spec } " )
330321
322+ def get_hashed_slug (self , url , changes_with_content ):
323+ """Return a unique slug that is invariant to query parameters in the url"""
324+ parsed_url = urlparse (url )
325+ stripped_url = urlunparse (
326+ (parsed_url .scheme , parsed_url .netloc , parsed_url .path , "" , "" , "" )
327+ )
328+ return "meca-" + md5 (f"{ stripped_url } -{ changes_with_content } " .encode ()).hexdigest ()
329+
331330 async def get_resolved_ref (self ):
332331 # Check the URL is reachable
333332 client = AsyncHTTPClient ()
@@ -336,11 +335,11 @@ async def get_resolved_ref(self):
336335 try :
337336 r = await client .fetch (req )
338337 self .log .info (f"URL is reachable: { self .url } " )
339- self .hashed_slug = get_hashed_slug (
338+ self .hashed_slug = self . get_hashed_slug (
340339 self .url , r .headers .get ("ETag" ) or r .headers .get ("Content-Length" )
341340 )
342341 except Exception as e :
343- raise ValueError (f"URL is unreachable ({ e } )" )
342+ raise RuntimeError (f"URL is unreachable ({ e } )" )
344343
345344 self .log .info (f"hashed_slug: { self .hashed_slug } " )
346345 return self .hashed_slug
0 commit comments