From acfe8f9820784a3c8f84ced7b40c4fd853d95034 Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Sun, 9 Jun 2019 12:57:17 +0200
Subject: [PATCH] Fixed broken etsy regex

---
 retribute_api/providers.py | 2 +-
 tests/search/test_means.py | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/retribute_api/providers.py b/retribute_api/providers.py
index 61d1c21..e604501 100644
--- a/retribute_api/providers.py
+++ b/retribute_api/providers.py
@@ -118,7 +118,7 @@ class Etsy(BasicUsernameInPathProvider):
     label = "Etsy"
     url = "https://etsy.com"
     domain_regex = r"^(\w+\.)*etsy\.com"
-    username_regex = r"^\/[a-zA-Z-_]+/shop/([\w\.]+)/?$"
+    username_regex = r"^\/(?:[a-zA-Z-_]+/)?shop/([\w\.]+)/?$"
 
 
 @registry.register
diff --git a/tests/search/test_means.py b/tests/search/test_means.py
index fffa4f9..75abd94 100644
--- a/tests/search/test_means.py
+++ b/tests/search/test_means.py
@@ -17,6 +17,10 @@ from retribute_api.search import means
             "https://www.etsy.com/fr_CA/shop/xxPETRICHORxx",
             {"provider": "etsy", "id": "xxPETRICHORxx"},
         ),
+        (
+            "https://www.etsy.com/shop/xxPETRICHORxx",
+            {"provider": "etsy", "id": "xxPETRICHORxx"},
+        ),
         ("https://tipeee.com/username", {"provider": "tipeee", "id": "username"}),
         (
             "https://custom.com/username?retribute",
-- 
GitLab