Skip to content

Commit

Permalink
fix: use realpath to detect if file is in root path
Browse files Browse the repository at this point in the history
  • Loading branch information
aladjadj committed May 11, 2022
1 parent 879bcfb commit f647a2c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mkdocs_monorepo_plugin/edit_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, config, page, plugin):
self.config = config
self.page = page
self.plugin = plugin

def __get_root_config_file_path(self):
return path.dirname(self.config['config_file_path'])

Expand Down Expand Up @@ -50,7 +50,7 @@ def __get_page_src_path(self):
def __get_page_config_file_path(self):
alias = self.__get_page_dir_alias()
return self.plugin.aliases[alias]['yaml_file']

def __load_page_config_file(self, file):
config = yaml_load(file)

Expand Down Expand Up @@ -89,7 +89,8 @@ def __is_root(self):
root_config_docs_dir = self.__get_root_docs_dir()
abs_root_config_file_dir = self.__get_root_config_file_path()
abs_root_config_docs_dir = path.join(abs_root_config_file_dir, root_config_docs_dir)
return abs_root_config_docs_dir in self.page.file.abs_src_path

return path.realpath(abs_root_config_docs_dir) in self.page.file.abs_src_path

def build(self):
if self.__is_root():
Expand All @@ -98,7 +99,7 @@ def build(self):
config = self.__get_page_config_file_yaml()
return config['repo_url'] + config['edit_uri'] + self.__get_page_src_path()
return None

def set_edit_url(config, page, plugin):
edit_url = EditUrl(config, page, plugin)
page.edit_url = edit_url.build()

0 comments on commit f647a2c

Please sign in to comment.