Skip to content

Commit

Permalink
feat(general): support mailto links
Browse files Browse the repository at this point in the history
  • Loading branch information
reitzig committed Sep 12, 2024
1 parent 5e03aeb commit efbca06
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions nice-dev-refs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ then type any of the following:

### Supported URL Formats

- Email links, i.e. `mailto:`
- **Bitbucket**: project, repository,
pull request (& comment, commit, file & line),
file (& line), file (& line) in pull request,
Expand Down
2 changes: 1 addition & 1 deletion nice-dev-refs/_manifest.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "nice-dev-refs"
title: "Nice Developer References"
description: Takes URLs from the clipboard and pastes them as nice links
version: 0.22.1
version: 0.23.0
author: Raphael Reitzig
4 changes: 3 additions & 1 deletion scripts/label_for_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def remove_prefix(text: str, prefix: str) -> str:


def determine_label(input_url: str) -> str:
if m := re.search(
if m := re.search(r"^mailto:(?P<email>.+@.+)$", input_url):
return f"{m.group('email')}"
elif m := re.search(
r"^https://[^/]*bitbucket[^/]*/(?:projects|users)/(?P<project>[^/]+)/repos/(?P<repo>[^/]+)/"
r"pull-requests/(?P<pr>\d+)/?"
r"(commits/(?P<commit>[a-fA-F0-9]+))?"
Expand Down
14 changes: 14 additions & 0 deletions test/test_general.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from assertpy import assert_that

from label_for_url import determine_label


def test_should_mailto() -> None:
# Given:
url = "mailto:[email protected]"

# When:
label = determine_label(url)

# Then:
assert_that(label).is_equal_to("[email protected]")

0 comments on commit efbca06

Please sign in to comment.