Skip to content

Conversation

@juanjemdIos
Copy link
Contributor

better readthedocs badges.

REGEXP_READTHEDOCS_HTML = (
r"<a\b[^>]+?href=['\"](https?://[^'\"\s]+?)['\"][^>]*?>"
r"(?:(?!</a>)[\s\S])*?"
r"<img\b[^>]+?src=['\"]https?://(?:readthedocs\.org/projects/|img\.shields\.io/pypi/)[^'\"\s]*"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regular expression is potentially dangerous, and it may be slow.
Try this one instead:

r"""
    <a\b
        [^>]*\bhref=['"](https?://[^'"\s]+)['"]
        [^>]*>
    (?:
        [^<]+             
        |
        <(?!/a\b)[^>]*>   
    )*
    <img\b
        [^>]*\bsrc=['"]
        https?://(?:readthedocs\.org/projects/|img\.shields\.io/pypi/)
        [^'"\s>]+
        ['"]
    """

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i'll try again after all test pass

self.assertTrue(len(package_results) > 0, "No package file info found")
self.assertEqual(package_results[0]["result"]["value"], "DESCRIPTION")
# self.assertEqual(package_results[0]["result"]["value"], "DESCRIPTION")
self.assertEqual(package_results[0]["result"]["value"], "https://example.org/DESCRIPTION")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this looking into example.org?
If somef is run locally and there is no repo, it should return the path to the file...

self.assertTrue(len(package_results) > 0, "No package file info found")
self.assertEqual(package_results[0]["result"]["value"], "bootstrap-datepicker-rails.gemspec")
# self.assertEqual(package_results[0]["result"]["value"], "bootstrap-datepicker-rails.gemspec")
self.assertEqual(package_results[0]["result"]["value"], "https://example.org/bootstrap-datepicker-rails.gemspec")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

self.assertTrue(len(package_results) > 0, "No package file info found")
self.assertEqual(package_results[0]["result"]["value"], "package.json")
# self.assertEqual(package_results[0]["result"]["value"], "package.json")
self.assertEqual(package_results[0]["result"]["value"], "http://example.com/package_neors.json")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

parse_toml_file(self.cargo_toml_path, result, "test")
# parse_toml_file(self.cargo_toml_path, result, "test")
print("self.cargo_toml_path:", self.cargo_toml_path)
parse_toml_file(self.cargo_toml_path, result, "http://example.com/rustdesk/Cargo.toml")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants