mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
465831175a
Summary: Autolinker is a great open source project but it attempts to parse HTML with regexp, is quite slow, and hangs on specific emails https://github.com/nylas/N1/issues/1540 This is super bad, and also super unnecessary. I think this should do the trick. Note: I changed the urlRegex in our Utils to be much more liberal. It now matches anything that looks like a URL, not just things with the http:// and https:// prefixes. It's used in the LinkEditor and onboarding screen (detecting auth errors with urls) and I think it should be ok? Test Plan: Need to write some tests Reviewers: evan, juan Reviewed By: juan Differential Revision: https://phab.nylas.com/D2725
24 lines
803 B
JavaScript
24 lines
803 B
JavaScript
import {autolink} from '../lib/autolinker';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
describe("autolink", () => {
|
|
const fixturesDir = path.join(__dirname, 'autolinker-fixtures');
|
|
fs.readdirSync(fixturesDir).filter(filename =>
|
|
filename.indexOf('-in.html') !== -1
|
|
).forEach((filename) => {
|
|
it(`should properly autolink a variety of email bodies ${filename}`, () => {
|
|
const div = document.createElement('div');
|
|
const inputPath = path.join(fixturesDir, filename);
|
|
const expectedPath = inputPath.replace('-in', '-out');
|
|
|
|
const input = fs.readFileSync(inputPath).toString();
|
|
const expected = fs.readFileSync(expectedPath).toString();
|
|
|
|
div.innerHTML = input;
|
|
autolink({body: div});
|
|
|
|
expect(div.innerHTML).toEqual(expected);
|
|
});
|
|
});
|
|
});
|