Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
to
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
matrix
to
Commits
c903de8b
Commit
c903de8b
authored
9 years ago
by
David Baker
Browse files
Options
Downloads
Patches
Plain Diff
Support Room ID links
Fixes
https://github.com/vector-im/vector-web/issues/1658
parent
63f67996
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+4
-0
4 additions, 0 deletions
README.md
src/components/HomePage.js
+12
-1
12 additions, 1 deletion
src/components/HomePage.js
with
16 additions
and
1 deletion
README.md
+
4
−
0
View file @
c903de8b
...
...
@@ -29,6 +29,7 @@ The matrix.to URL scheme is:
| Entity type: | Example URL |
|--------------|-------------------------------------------------------------------|
| Rooms: | https://matrix.to/#/#matrix:matrix.org |
| Rooms by ID: | https://matrix.to/#/!cURbafjkfsMDVwdRDQ:matrix.org |
| Users: | https://matrix.to/#/@matthew:matrix.org |
| Messages: | https://matrix.to/#/#matrix:matrix.org/$1448831580433WbpiJ:jki.re |
...
...
@@ -36,5 +37,8 @@ The #/ component is optional, and exists to avoid leaking the target URL to the
server hosting matrix.to. https://matrix.to/@matthew:matrix.org works too, and
provides better legibility at the expense of privacy.
Note that linking to rooms by ID should only be used for rooms to which the target
user has been invited: these links cannot be assumed to work for all visitors.
(Technically the # and @ in the URL fragment should probably be escaped, but in
practice for legibility we bend the rules and include it verbatim)
This diff is collapsed.
Click to expand it.
src/components/HomePage.js
+
12
−
1
View file @
c903de8b
...
...
@@ -23,6 +23,7 @@ var linkable_clients = [
author
:
"
Vector.im
"
,
homepage
:
"
https://vector.im
"
,
room_url
(
alias
)
{
return
"
https://vector.im/beta/#/room/
"
+
alias
},
room_id_url
(
id
)
{
return
"
https://vector.im/beta/#/room/
"
+
id
},
user_url
(
userId
)
{
return
"
https://vector.im/beta/#/user/
"
+
userId
},
msg_url
(
msg
)
{
return
"
https://vector.im/beta/#/room/
"
+
msg
},
maturity
:
"
Late beta
"
,
...
...
@@ -34,6 +35,7 @@ var linkable_clients = [
author
:
"
Matrix.org
"
,
homepage
:
"
https://matrix.org
"
,
room_url
(
alias
)
{
return
"
https://matrix.org/beta/#/room/
"
+
alias
},
room_id_url
(
id
)
{
return
"
https://matrix.org/beta/#/room/
"
+
id
},
maturity
:
"
Deprecated
"
,
comments
:
"
The original developer-focused client for Web, iOS & Android
"
,
},
...
...
@@ -122,7 +124,7 @@ export default React.createClass({
return
;
}
if
(
!
this
.
isAliasValid
(
entity
)
&&
!
this
.
isUserIdValid
(
entity
)
&&
!
this
.
isMsglinkValid
(
entity
))
{
if
(
!
this
.
isAliasValid
(
entity
)
&&
!
this
.
isUserIdValid
(
entity
)
&&
!
this
.
isMsglinkValid
(
entity
)
&&
!
this
.
isRoomIdValid
(
entity
)
)
{
this
.
setState
({
entity
:
entity
,
error
:
"
Invalid room alias, user ID or message permalink '
"
+
entity
+
"
'
"
,
...
...
@@ -174,6 +176,11 @@ export default React.createClass({
return
(
alias
.
match
(
/^#
([^\/
:
]
+
?)
:
(
.+
)
$/
)
&&
encodeURI
(
alias
)
===
alias
);
},
isRoomIdValid
(
id
)
{
// XXX: FIXME SPEC-1
return
(
id
.
match
(
/^!
([^\/
:
]
+
?)
:
(
.+
)
$/
)
&&
encodeURI
(
id
)
===
id
);
},
isUserIdValid
(
userId
)
{
// XXX: FIXME SPEC-1
return
(
userId
.
match
(
/^@
([^\/
:
]
+
?)
:
(
.+
)
$/
)
&&
encodeURI
(
userId
)
===
userId
);
...
...
@@ -197,6 +204,7 @@ export default React.createClass({
var
link
=
"
https://matrix.to/#/
"
+
this
.
state
.
entity
;
var
isRoom
=
this
.
isAliasValid
(
this
.
state
.
entity
);
var
isRoomId
=
this
.
isRoomIdValid
(
this
.
state
.
entity
);
var
isUser
=
this
.
isUserIdValid
(
this
.
state
.
entity
);
var
isMsg
=
this
.
isMsglinkValid
(
this
.
state
.
entity
);
...
...
@@ -258,6 +266,9 @@ export default React.createClass({
if
(
isRoom
&&
client
.
room_url
)
{
link
=
client
.
room_url
(
this
.
state
.
entity
);
}
else
if
(
isRoomId
&&
client
.
room_id_url
)
{
link
=
client
.
room_id_url
(
this
.
state
.
entity
);
}
else
if
(
isUser
&&
client
.
user_url
)
{
link
=
client
.
user_url
(
this
.
state
.
entity
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment