Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
uritemplate-js
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
uritemplate-js
Commits
47ba089e
Commit
47ba089e
authored
Jan 21, 2013
by
Ruben Verborgh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly encode percent signs in URIs.
parent
21505bd8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
16 deletions
+7
-16
LiteralExpression.js
src/LiteralExpression.js
+2
-7
encodingHelper.js
src/encodingHelper.js
+2
-7
rfcCharHelper.js
src/rfcCharHelper.js
+2
-1
uritemplate-test
uritemplate-test
+1
-1
No files found.
src/LiteralExpression.js
View file @
47ba089e
...
...
@@ -9,13 +9,8 @@ var LiteralExpression = (function () {
index
,
chr
=
''
;
for
(
index
=
0
;
index
<
literal
.
length
;
index
+=
chr
.
length
)
{
chr
=
pctEncoder
.
pctCharAt
(
literal
,
index
);
if
(
chr
.
length
>
0
)
{
result
+=
chr
;
}
else
{
result
+=
rfcCharHelper
.
isReserved
(
chr
)
||
rfcCharHelper
.
isUnreserved
(
chr
)
?
chr
:
pctEncoder
.
encodeCharacter
(
chr
);
}
chr
=
literal
.
charAt
(
index
);
result
+=
rfcCharHelper
.
isReserved
(
chr
)
||
rfcCharHelper
.
isUnreserved
(
chr
)
?
chr
:
pctEncoder
.
encodeCharacter
(
chr
);
}
return
result
;
}
...
...
src/encodingHelper.js
View file @
47ba089e
...
...
@@ -15,13 +15,8 @@ var encodingHelper = (function () {
text
=
text
.
toString
();
}
for
(
index
=
0
;
index
<
text
.
length
;
index
+=
chr
.
length
)
{
chr
=
pctEncoder
.
pctCharAt
(
text
,
index
);
if
(
chr
.
length
>
1
)
{
result
+=
chr
;
}
else
{
result
+=
rfcCharHelper
.
isUnreserved
(
chr
)
||
(
passReserved
&&
rfcCharHelper
.
isReserved
(
chr
))
?
chr
:
pctEncoder
.
encodeCharacter
(
chr
);
}
chr
=
text
.
charAt
(
index
);
result
+=
rfcCharHelper
.
isUnreserved
(
chr
)
||
(
passReserved
&&
rfcCharHelper
.
isReserved
(
chr
))
?
chr
:
pctEncoder
.
encodeCharacter
(
chr
);
}
return
result
;
}
...
...
src/rfcCharHelper.js
View file @
47ba089e
...
...
@@ -23,12 +23,13 @@ var rfcCharHelper = (function () {
/**
* Returns if chr is an reserved character according 1.5 of rfc 6570
* or the percent character mentioned in 3.2.1.
* @param chr
* @return {Boolean}
*/
function
isReserved
(
chr
)
{
return
chr
===
':'
||
chr
===
'/'
||
chr
===
'?'
||
chr
===
'#'
||
chr
===
'['
||
chr
===
']'
||
chr
===
'@'
||
chr
===
'!'
||
chr
===
'$'
||
chr
===
'&'
||
chr
===
'('
||
chr
===
')'
||
chr
===
'*'
||
chr
===
'+'
||
chr
===
','
||
chr
===
';'
||
chr
===
'='
||
chr
===
"'"
;
chr
===
')'
||
chr
===
'*'
||
chr
===
'+'
||
chr
===
','
||
chr
===
';'
||
chr
===
'='
||
chr
===
"'"
||
chr
===
'%'
;
}
return
{
...
...
uritemplate-test
@
b317372c
Subproject commit
6aad87eb6f7763e9806b9345dd90e697be6b1bbf
Subproject commit
b317372c613f1aab82f1e497146b2859144b9308
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