mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-20 10:48:40 +01:00
Make contextual matching of project monograms more liberal
Summary: We currently share the same regexp between PHID matching (usually unambiguous) and remarkup matching (often ambiguous). This means that some project monograms which should work fine don't work properly in some contexts. Improve these behaviors. For example: - `#domain.com` - Previously did not work at all. - Now works in unambiguous cases, and in remarkup. - `#1` - Previously did not work at all. - Now works in unambiguous cases. - `#dot.` - Previously did not work at all. - Now works in unambiguous cases. Test Plan: - Created projects `domain.com`, `1`, etc. - Used jump nav to match them unambiguously, everything worked. - Used remarkup preview to match them ambiguously, the reasonable ones worked. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D8703
This commit is contained in:
parent
9f8d35ae0e
commit
7f81fd4bf4
2 changed files with 18 additions and 9 deletions
|
@ -52,10 +52,8 @@ final class PhabricatorProjectPHIDTypeProject extends PhabricatorPHIDType {
|
|||
}
|
||||
|
||||
public static function getProjectMonogramPatternFragment() {
|
||||
// NOTE: This explicitly does not match strings which contain only
|
||||
// digits, because digit strings like "#123" are used to reference tasks at
|
||||
// Facebook and are somewhat conventional in general.
|
||||
return '[^\s.!,:;{}#]*[^\s\d.!,:;{}#]+[^\s.!,:;{}#]*';
|
||||
// NOTE: See some discussion in ProjectRemarkupRule.
|
||||
return '[^\s,#]+';
|
||||
}
|
||||
|
||||
public function canLoadNamedObject($name) {
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group project
|
||||
*/
|
||||
final class ProjectRemarkupRule
|
||||
extends PhabricatorRemarkupRuleObject {
|
||||
|
||||
|
@ -11,8 +8,22 @@ final class ProjectRemarkupRule
|
|||
}
|
||||
|
||||
protected function getObjectIDPattern() {
|
||||
return
|
||||
PhabricatorProjectPHIDTypeProject::getProjectMonogramPatternFragment();
|
||||
// NOTE: This explicitly does not match strings which contain only
|
||||
// digits, because digit strings like "#123" are used to reference tasks at
|
||||
// Facebook and are somewhat conventional in general.
|
||||
|
||||
// The latter half of this rule matches monograms with internal periods,
|
||||
// like `#domain.com`, but does not match monograms with terminal periods,
|
||||
// because they're probably just puncutation.
|
||||
|
||||
// Broadly, this will not match every possible project monogram, and we
|
||||
// accept some false negatives -- like `#1` or `#dot.` -- in order to avoid
|
||||
// a bunch of false positives on general use of the `#` character.
|
||||
|
||||
// In other contexts, the PhabricatorProjectPHIDTypeProject pattern is
|
||||
// controlling and these names should parse correctly.
|
||||
|
||||
return '[^\s.!,:;{}#]*[^\s\d!,:;{}#]+(?:[^\s.!,:;{}#][^\s!,:;{}#]*)*';
|
||||
}
|
||||
|
||||
protected function loadObjects(array $ids) {
|
||||
|
|
Loading…
Add table
Reference in a new issue