Skip to content

Commit

Permalink
Merge pull request #998 from AppFlowy-IO/feat/allow-underscore-in-url
Browse files Browse the repository at this point in the history
feat: allow underscore in publish url
  • Loading branch information
speed2exe authored Nov 16, 2024
2 parents 655f13b + 4703b90 commit 7c6a706
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/biz/workspace/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn check_collab_publish_name(publish_name: &str) -> Result<(), AppError> {

// Only contain alphanumeric characters and hyphens
for c in publish_name.chars() {
if !c.is_alphanumeric() && c != '-' {
if !c.is_alphanumeric() && c != '-' && c != '_' {
return Err(AppError::PublishNameInvalidCharacter { character: c });
}
}
Expand Down Expand Up @@ -246,8 +246,9 @@ pub async fn list_collab_publish_info(
async fn check_workspace_namespace(new_namespace: &str) -> Result<(), AppError> {
// Must be url safe
// Only contain alphanumeric characters and hyphens
// and underscores (discouraged)
for c in new_namespace.chars() {
if !c.is_alphanumeric() && c != '-' {
if !c.is_alphanumeric() && c != '-' && c != '_' {
return Err(AppError::CustomNamespaceInvalidCharacter { character: c });
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/workspace/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async fn test_set_publish_namespace_set() {
.unwrap();
}

let new_namespace = uuid::Uuid::new_v4().to_string();
let new_namespace = format!("namespace_{}", uuid::Uuid::new_v4());
c.set_workspace_publish_namespace(&workspace_id.to_string(), new_namespace.clone())
.await
.unwrap();
Expand Down Expand Up @@ -156,9 +156,9 @@ async fn test_publish_doc() {
assert_eq!(err.code, ErrorCode::PublishNameTooLong, "{:?}", err);
}

let publish_name_1 = "publish-name-1";
let publish_name_1 = "publish_name-1";
let view_id_1 = uuid::Uuid::new_v4();
let publish_name_2 = "publish-name-2";
let publish_name_2 = "publish_name-2";
let view_id_2 = uuid::Uuid::new_v4();

// User publishes two collabs
Expand Down

0 comments on commit 7c6a706

Please sign in to comment.