mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-10 02:03:07 +08:00
fix(autolinker): Add more test cases, improv URL regex
This commit is contained in:
parent
1ad2598a50
commit
73afdbb482
5 changed files with 166 additions and 8 deletions
|
@ -84,7 +84,7 @@ Ben Gotow (Careless)</span><br>
|
|||
<td style="line-height: 1.5;"><span style="font-family: Roboto-Regular,Helvetica,Arial,sans-serif; font-size: 16px; color: #202020;">
|
||||
Mac</span><br>
|
||||
<span style="font-family: Roboto-Regular,Helvetica,Arial,sans-serif; font-size: 13px; color: #727272;">
|
||||
Monday, July 13, 2015 3:49 PM (Pacific Daylight Time)<br>
|
||||
Monday, July 13, <a href="2015 3:49" title="2015 3:49">2015 3:49</a> PM (Pacific Daylight Time)<br>
|
||||
San Francisco, CA, USA*<br>
|
||||
Chrome</span></td>
|
||||
</tr>
|
||||
|
|
|
@ -3,10 +3,8 @@
|
|||
|
||||
<title></title>
|
||||
|
||||
<a href="
|
||||
http://apple.com/" title="
|
||||
http://apple.com/">
|
||||
http://apple.com/</a>
|
||||
|
||||
<a href="http://apple.com/" title="http://apple.com/">http://apple.com/</a>
|
||||
<div><br></div>
|
||||
<div><a href="https://dropbox.com/" title="https://dropbox.com/">https://dropbox.com/</a></div>
|
||||
<div><br></div>
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
To get up and running with the api you'll need to follow these steps.
|
||||
|
||||
1. Once you feel familiar with the endpoints and http responses go ham!!!
|
||||
|
||||
## Support
|
||||
|
||||
Please [open an issue](https://github.com/a/b/issues/new) for support.
|
||||
|
||||
## Contributing
|
||||
If you would like to contribute to the axefax api (which you are encouraged to do) here are the basics.
|
||||
|
||||
- Ruby version: 2.2.2
|
||||
- System dependencies: Rails, AWS, postgres, eb-cli
|
||||
- Configuration:
|
||||
```bash
|
||||
$ git clone https://github.com/a/b.git
|
||||
$ bundle install
|
||||
```
|
||||
- Database intitialization/creation:
|
||||
```bash
|
||||
$ rake db:reset db:setup db:seed
|
||||
```
|
||||
- How to run the test suite:
|
||||
```bash
|
||||
$ rspec spec
|
||||
```
|
||||
- or alternatively:
|
||||
```bash
|
||||
$ guard
|
||||
```
|
||||
- run the server:
|
||||
```bash
|
||||
$ rails server
|
||||
```
|
||||
- Git Guidelines:
|
||||
- Please create a contributor/feature branch for any changes you make.
|
||||
- Be sure to always pull down the latest master branch before pushing.
|
||||
- etc...
|
||||
- Generating Documentation:
|
||||
- This app makes use of the (Apipie Gem)[https://github.com/Apipie/apipie-rails]
|
||||
- To Auto/Re-Generate Documentation for API Endpoints based on config/routes.rb
|
||||
and the spec suite run...
|
||||
```bash
|
||||
$ APIPIE_RECORD=params rake spec:controllers
|
||||
$ APIPIE_RECORD=examples rake spec:controllers
|
||||
```
|
||||
- Then to generate static HTML files for production...
|
||||
```bash
|
||||
$ rake apipie:static
|
||||
```
|
||||
- Deployment instructions:
|
||||
- If the test suite is passing and you've successfully merged to master and pushed up to github...
|
||||
```bash
|
||||
$ eb deploy
|
||||
```
|
||||
- Hopefully you won't need to ssh into the remote server to run migrations but if you do...
|
||||
```bash
|
||||
$ eb ssh
|
||||
remote:ec2 ~ $ cd /var/app/current/
|
||||
```
|
||||
- From here you have access to a limited set of railsy stuffs. But for example rake db:migrate
|
|
@ -0,0 +1,61 @@
|
|||
To get up and running with the api you'll need to follow these steps.
|
||||
|
||||
1. Once you feel familiar with the endpoints and http responses go ham!!!
|
||||
|
||||
## Support
|
||||
|
||||
Please [open an issue](<a href="https://github.com/a/b/issues/new" title="https://github.com/a/b/issues/new">https://github.com/a/b/issues/new</a>) for support.
|
||||
|
||||
## Contributing
|
||||
If you would like to contribute to the axefax api (which you are encouraged to do) here are the basics.
|
||||
|
||||
- Ruby version: 2.2.2
|
||||
- System dependencies: Rails, AWS, postgres, eb-cli
|
||||
- Configuration:
|
||||
```bash
|
||||
$ git clone <a href="https://github.com/a/b.git" title="https://github.com/a/b.git">https://github.com/a/b.git</a>
|
||||
$ bundle install
|
||||
```
|
||||
- Database intitialization/creation:
|
||||
```bash
|
||||
$ rake db:reset db:setup db:seed
|
||||
```
|
||||
- How to run the test suite:
|
||||
```bash
|
||||
$ rspec spec
|
||||
```
|
||||
- or alternatively:
|
||||
```bash
|
||||
$ guard
|
||||
```
|
||||
- run the server:
|
||||
```bash
|
||||
$ rails server
|
||||
```
|
||||
- Git Guidelines:
|
||||
- Please create a contributor/feature branch for any changes you make.
|
||||
- Be sure to always pull down the latest master branch before pushing.
|
||||
- etc...
|
||||
- Generating Documentation:
|
||||
- This app makes use of the (Apipie Gem)[<a href="https://github.com/Apipie/apipie-rails" title="https://github.com/Apipie/apipie-rails">https://github.com/Apipie/apipie-rails</a>]
|
||||
- To Auto/Re-Generate Documentation for API Endpoints based on config/<a href="routes.rb" title="routes.rb">routes.rb</a>
|
||||
and the spec suite run...
|
||||
```bash
|
||||
$ APIPIE_RECORD=params rake spec:controllers
|
||||
$ APIPIE_RECORD=examples rake spec:controllers
|
||||
```
|
||||
- Then to generate static HTML files for production...
|
||||
```bash
|
||||
$ rake apipie:static
|
||||
```
|
||||
- Deployment instructions:
|
||||
- If the test suite is passing and you've successfully merged to master and pushed up to github...
|
||||
```bash
|
||||
$ eb deploy
|
||||
```
|
||||
- Hopefully you won't need to ssh into the remote server to run migrations but if you do...
|
||||
```bash
|
||||
$ eb ssh
|
||||
remote:ec2 ~ $ cd /var/app/current/
|
||||
```
|
||||
- From here you have access to a limited set of railsy stuffs. But for example rake db:migrate
|
|
@ -27,10 +27,48 @@ RegExpUtils =
|
|||
|
||||
# Test cases: https://regex101.com/r/pD7iS5/3
|
||||
urlRegex: ({matchEntireString} = {}) ->
|
||||
parts = [
|
||||
'('
|
||||
# one of:
|
||||
'('
|
||||
# optional scheme, ala https://
|
||||
'([A-Za-z]{3,9}:(?:\\/\\/))?'
|
||||
|
||||
# optional username:password
|
||||
'(?:[\\-;:&=\\+\\$,\\w]+@)?'
|
||||
|
||||
# one of:
|
||||
'('
|
||||
# domain
|
||||
'([a-zA-Z0-9-_]+\\.)*[a-zA-Z0-9][a-zA-Z0-9-_]+\\.[a-zA-Z]{2,11}'
|
||||
|
||||
'|'
|
||||
|
||||
# ip address
|
||||
'(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
||||
')'
|
||||
|
||||
'|'
|
||||
|
||||
# mailto:username@password.com
|
||||
'mailto:\\/*(?:\\w+\\.|[\\-;:&=\\+\\$.,\\w]+@)[A-Za-z0-9\\.\\-]+'
|
||||
')'
|
||||
|
||||
# optionally followed by:
|
||||
'('
|
||||
# URL components
|
||||
'(?:\\/[\\+~%\\/\\.\\w\\-_]*)?'
|
||||
# optionally followed by a ?
|
||||
'\\??'
|
||||
# optionally followed by a query string
|
||||
'(?:[\\-\\+=&;%@\\.\\w_]*)#?(?:[\\.\\!\\/\\\\\\w]*)'
|
||||
')?'
|
||||
')'
|
||||
]
|
||||
if matchEntireString
|
||||
new RegExp(/^((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:[\w\-]+\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/g)
|
||||
else
|
||||
new RegExp(/(?:^|\s)((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:[\w\-]+\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/g)
|
||||
parts.unshift('^')
|
||||
|
||||
return new RegExp(parts.join(''), 'g')
|
||||
|
||||
# Test cases: https://regex101.com/r/jD5zC7/2
|
||||
# Returns the following capturing groups:
|
||||
|
|
Loading…
Reference in a new issue