Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3386250
D4443.id14744.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D4443.id14744.diff
View Options
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -269,6 +269,9 @@
return `pending/${pendingThreadTypeString}${pendingThreadKey}`;
}
+const locallyUniqueThreadIDRegex =
+ 'pending/(type[0-9]+/[0-9]+(\\+[0-9]+)*|sidebar/[0-9]+)';
+
type CreatePendingThreadArgs = {
+viewerID: string,
+threadType: ThreadType,
@@ -1381,6 +1384,7 @@
threadIsPending,
getSingleOtherUser,
getLocallyUniqueThreadID,
+ locallyUniqueThreadIDRegex,
createPendingThread,
createPendingThreadItem,
createPendingSidebar,
diff --git a/lib/utils/url-utils.js b/lib/utils/url-utils.js
--- a/lib/utils/url-utils.js
+++ b/lib/utils/url-utils.js
@@ -2,6 +2,8 @@
import urlParseLax from 'url-parse-lax';
+import { locallyUniqueThreadIDRegex } from '../shared/thread-utils';
+
export type URLInfo = {
+year?: number,
+month?: number, // 1-indexed
@@ -14,6 +16,8 @@
...
};
+// We use groups to capture parts of the URL and any changes
+// to regexes must be reflected in infoFromURL.
const yearRegex = new RegExp('(/|^)year/([0-9]+)(/|$)', 'i');
const monthRegex = new RegExp('(/|^)month/([0-9]+)(/|$)', 'i');
const threadRegex = new RegExp('(/|^)thread/([0-9]+)(/|$)', 'i');
@@ -23,6 +27,10 @@
const appsRegex = new RegExp('(/|^)apps(/|$)', 'i');
const accountSettingsRegex = new RegExp('(/|^)settings/account(/|$)', 'i');
const dangerZoneRegex = new RegExp('(/|^)settings/danger-zone(/|$)', 'i');
+const threadPendingRegex = new RegExp(
+ `(/|^)thread/(${locallyUniqueThreadIDRegex})(/|$)`,
+ 'i',
+);
function infoFromURL(url: string): URLInfo {
const yearMatches = yearRegex.exec(url);
@@ -34,6 +42,7 @@
const appsTest = appsRegex.test(url);
const accountSettingsTest = accountSettingsRegex.test(url);
const dangerZoneTest = dangerZoneRegex.test(url);
+ const threadPendingMatches = threadPendingRegex.exec(url);
const returnObj = {};
if (yearMatches) {
@@ -49,6 +58,9 @@
if (threadMatches) {
returnObj.thread = threadMatches[2];
}
+ if (threadPendingMatches) {
+ returnObj.thread = threadPendingMatches[2];
+ }
if (verifyMatches) {
returnObj.verify = verifyMatches[2];
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 30, 4:03 AM (21 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2599193
Default Alt Text
D4443.id14744.diff (2 KB)
Attached To
Mode
D4443: [lib] Support pending threads in `URLInfo` calculation
Attached
Detach File
Event Timeline
Log In to Comment