MCPcopy
hub / github.com/vrcx-team/VRCX / parseLocation

Function parseLocation

src/shared/utils/locationParser.js:32–142  ·  view source on GitHub ↗

* * @param {string} tag * @returns

(tag)

Source from the content-addressed store, hash-verified

30 * @returns
31 */
32function parseLocation(tag) {
33 let _tag = String(tag || '');
34 const ctx = {
35 tag: _tag,
36 isOffline: false,
37 isPrivate: false,
38 isTraveling: false,
39 isRealInstance: false,
40 worldId: '',
41 instanceId: '',
42 instanceName: '',
43 accessType: '',
44 accessTypeName: '',
45 region: '',
46 shortName: '',
47 userId: null,
48 hiddenId: null,
49 privateId: null,
50 friendsId: null,
51 groupId: null,
52 groupAccessType: null,
53 canRequestInvite: false,
54 strict: false,
55 ageGate: false
56 };
57 if (_tag === 'offline' || _tag === 'offline:offline') {
58 ctx.isOffline = true;
59 } else if (_tag === 'private' || _tag === 'private:private') {
60 ctx.isPrivate = true;
61 } else if (_tag === 'traveling' || _tag === 'traveling:traveling') {
62 ctx.isTraveling = true;
63 } else if (tag && !_tag.startsWith('local')) {
64 ctx.isRealInstance = true;
65 const sep = _tag.indexOf(':');
66 // technically not part of instance id, but might be there when coping id from url so why not support it
67 const shortNameQualifier = '&shortName=';
68 const shortNameIndex = _tag.indexOf(shortNameQualifier);
69 if (shortNameIndex >= 0) {
70 ctx.shortName = _tag.substr(
71 shortNameIndex + shortNameQualifier.length
72 );
73 _tag = _tag.substr(0, shortNameIndex);
74 }
75 if (sep >= 0) {
76 ctx.worldId = _tag.substr(0, sep);
77 ctx.instanceId = _tag.substr(sep + 1);
78 ctx.instanceId.split('~').forEach((s, i) => {
79 if (i) {
80 const A = s.indexOf('(');
81 const Z = A >= 0 ? s.lastIndexOf(')') : -1;
82 const key = Z >= 0 ? s.substr(0, A) : s;
83 const value = A < Z ? s.substr(A + 1, Z - A - 1) : '';
84 if (key === 'hidden') {
85 ctx.hiddenId = value;
86 } else if (key === 'private') {
87 ctx.privateId = value;
88 } else if (key === 'friends') {
89 ctx.friendsId = value;

Callers 15

addGameLogEntryFunction · 0.90
showWorldDialogFunction · 0.90
runHomeLocationSyncFlowFunction · 0.90
applyUserFunction · 0.90
applyCurrentUserFunction · 0.90
updateAutoStateChangeFunction · 0.90
runHandleUserUpdateFlowFunction · 0.90
updateNewInstanceDialogFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected