Fix Users API Token API path (#526)

* Fix Users API Token API path

* Change CRLF to LF

* Fix route generation when route contains /api
This commit is contained in:
sephrat 2021-06-16 20:31:09 +02:00 committed by GitHub
parent f5ede73eb6
commit db3c8f7b4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -29,7 +29,7 @@ JS_DIR.mkdir(exist_ok=True, parents=True)
class RouteObject:
def __init__(self, route_string) -> None:
self.prefix = "/" + route_string.split("/")[1]
self.route = route_string.replace(self.prefix, "")
self.route = "/" + route_string.split("/", 2)[2]
self.js_route = self.route.replace("{", "${")
self.parts = route_string.split("/")[1:]
self.var = re.findall(r"\{(.*?)\}", route_string)

View file

@ -46,7 +46,7 @@ class AppRoutes:
self.themes = "/api/themes"
self.themes_create = "/api/themes/create"
self.users = "/api/users"
self.users_api_tokens = "/api/users-tokens"
self.users_api_tokens = "/api/users/api-tokens"
self.users_self = "/api/users/self"
self.users_sign_ups = "/api/users/sign-ups"
self.utils_download = "/api/utils/download"
@ -127,7 +127,7 @@ class AppRoutes:
return f"{self.prefix}/themes/{id}"
def users_api_tokens_token_id(self, token_id):
return f"{self.prefix}/users-tokens/{token_id}"
return f"{self.prefix}/users/api-tokens/{token_id}"
def users_id(self, id):
return f"{self.prefix}/users/{id}"

View file

@ -42,7 +42,7 @@ export const API_ROUTES = {
themes: `${prefix}/themes`,
themesCreate: `${prefix}/themes/create`,
users: `${prefix}/users`,
usersApiTokens: `${prefix}/users-tokens`,
usersApiTokens: `${prefix}/users/api-tokens`,
usersSelf: `${prefix}/users/self`,
usersSignUps: `${prefix}/users/sign-ups`,
utilsDownload: `${prefix}/utils/download`,
@ -76,7 +76,7 @@ export const API_ROUTES = {
siteSettingsCustomPagesId: id => `${prefix}/site-settings/custom-pages/${id}`,
tagsTag: tag => `${prefix}/tags/${tag}`,
themesId: id => `${prefix}/themes/${id}`,
usersApiTokensTokenId: token_id => `${prefix}/users-tokens/${token_id}`,
usersApiTokensTokenId: token_id => `${prefix}/users/api-tokens/${token_id}`,
usersId: id => `${prefix}/users/${id}`,
usersIdFavorites: id => `${prefix}/users/${id}/favorites`,
usersIdFavoritesSlug: (id, slug) => `${prefix}/users/${id}/favorites/${slug}`,