Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
811ac6f0
Commit
811ac6f0
authored
Oct 01, 2015
by
Robert Knight
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2570 from hypothesis/Kj8vWkme-show-filenames-of-local-files
Show filenames of local documents with titles
parents
8595292f
2072d9ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
document-domain.js
h/static/scripts/filter/document-domain.js
+9
-0
document-domain-test.js
h/static/scripts/filter/test/document-domain-test.js
+20
-0
No files found.
h/static/scripts/filter/document-domain.js
View file @
811ac6f0
...
...
@@ -13,9 +13,18 @@ module.exports = function() {
*
*/
function
documentDomainFilter
(
document
)
{
var
uri
=
escapeHtml
(
document
.
uri
||
''
);
var
domain
=
escapeHtml
(
document
.
domain
||
''
);
var
title
=
escapeHtml
(
document
.
title
||
''
);
if
(
uri
.
startsWith
(
'file://'
)
&&
title
)
{
var
parts
=
uri
.
split
(
'/'
);
var
filename
=
parts
[
parts
.
length
-
1
];
if
(
filename
)
{
return
'('
+
filename
+
')'
;
}
}
if
(
domain
&&
domain
!==
title
)
{
return
'('
+
domain
+
')'
;
}
else
{
...
...
h/static/scripts/filter/test/document-domain-test.js
View file @
811ac6f0
...
...
@@ -29,6 +29,15 @@ describe('documentDomain', function() {
assert
(
domain
===
''
);
});
it
(
'returns the filename for local documents with titles'
,
function
()
{
var
domain
=
documentDomainFilterProvider
()({
title
:
'example.com'
,
uri
:
'file:///home/seanh/MyFile.pdf'
});
assert
(
domain
===
'(MyFile.pdf)'
);
});
it
(
'escapes HTML in the document domain'
,
function
()
{
var
spamLink
=
'<a href="http://example.com/rubies">Buy rubies!!!</a>'
;
...
...
@@ -39,4 +48,15 @@ describe('documentDomain', function() {
assert
(
domain
.
indexOf
(
spamLink
)
===
-
1
);
});
it
(
'escapes HTML in the document uri'
,
function
()
{
var
spamLink
=
'<a href="http://example.com/rubies">Buy rubies!!!</a>'
;
var
domain
=
documentDomainFilterProvider
()({
title
:
'title'
,
uri
:
'file:///home/seanh/'
+
spamLink
});
assert
(
domain
.
indexOf
(
spamLink
)
===
-
1
);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment