Skip to content

Commit ed7ace5

Browse files
authored
Allow '+' in keywords (#5046)
* Allow '+' in keywords For example: keywords = ["c++"]. * Add good keyword test
1 parent 6da9189 commit ed7ace5

File tree

3 files changed

+75
-1
lines changed

3 files changed

+75
-1
lines changed

src/models/keyword.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl Keyword {
5656
Some(c) => c,
5757
};
5858
first.is_ascii_alphanumeric()
59-
&& chars.all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '-')
59+
&& chars.all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '-' || c == '+')
6060
}
6161

6262
pub fn update_crate(conn: &PgConnection, krate: &Crate, keywords: &[&str]) -> QueryResult<()> {
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
[
2+
{
3+
"request": {
4+
"uri": "http://alexcrichton-test.s3.amazonaws.com/crates/foo_good_key/foo_good_key-1.0.0.crate",
5+
"method": "PUT",
6+
"headers": [
7+
[
8+
"accept",
9+
"*/*"
10+
],
11+
[
12+
"accept-encoding",
13+
"gzip"
14+
],
15+
[
16+
"content-length",
17+
"35"
18+
],
19+
[
20+
"content-type",
21+
"application/gzip"
22+
]
23+
],
24+
"body": "H4sIAAAAAAAA/+3AAQEAAACCIP+vbkhQwKsBLq+17wAEAAA="
25+
},
26+
"response": {
27+
"status": 200,
28+
"headers": [],
29+
"body": ""
30+
}
31+
},
32+
{
33+
"request": {
34+
"uri": "http://alexcrichton-test.s3.amazonaws.com/fo/o_/foo_good_key",
35+
"method": "PUT",
36+
"headers": [
37+
[
38+
"accept",
39+
"*/*"
40+
],
41+
[
42+
"accept-encoding",
43+
"gzip"
44+
],
45+
[
46+
"content-length",
47+
"166"
48+
],
49+
[
50+
"content-type",
51+
"text/plain"
52+
]
53+
],
54+
"body": "eyJuYW1lIjoiZm9vX2dvb2Rfa2V5IiwidmVycyI6IjEuMC4wIiwiZGVwcyI6W10sImNrc3VtIjoiYWNiNTYwNGIxMjZhYzg5NGMxZWIxMWM0NTc1YmYyMDcyZmVhNjEyMzJhODg4ZTQ1Mzc3MGM3OWQ3ZWQ1NjQxOSIsImZlYXR1cmVzIjp7fSwieWFua2VkIjpmYWxzZSwibGlua3MiOm51bGx9Cg=="
55+
},
56+
"response": {
57+
"status": 200,
58+
"headers": [],
59+
"body": ""
60+
}
61+
}
62+
]

src/tests/krate/publish.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,18 @@ fn publish_after_removing_documentation() {
710710
assert_eq!(json.krate.documentation, None);
711711
}
712712

713+
#[test]
714+
fn good_keywords() {
715+
let (_, _, _, token) = TestApp::full().with_token();
716+
let crate_to_publish = PublishBuilder::new("foo_good_key")
717+
.keyword("c++")
718+
.keyword("crates-io_index")
719+
.keyword("1password");
720+
let json = token.publish_crate(crate_to_publish).good();
721+
assert_eq!(json.krate.name, "foo_good_key");
722+
assert_eq!(json.krate.max_version, "1.0.0");
723+
}
724+
713725
#[test]
714726
fn bad_keywords() {
715727
let (_, _, _, token) = TestApp::full().with_token();

0 commit comments

Comments
 (0)