Skip to content

Commit

Permalink
🐛 导航管理自定义链接中的空格替换为短横线 Fix #132
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed May 26, 2020
1 parent b5bd60a commit 1609973
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/org/b3log/solo/service/PageMgmtService.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
package org.b3log.solo.service;

import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -31,7 +32,7 @@
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://vanessa.b3log.org">Vanessa</a>
* @version 1.1.0.20, Apr 15, 2020
* @version 1.1.1.0, May 26, 2020
* @since 0.4.0
*/
@Service
Expand Down Expand Up @@ -120,7 +121,8 @@ public void updatePage(final JSONObject requestJSONObject) throws ServiceExcepti
final JSONObject oldPage = pageRepository.get(pageId);
final JSONObject newPage = new JSONObject(page, JSONObject.getNames(page));
newPage.put(Page.PAGE_ORDER, oldPage.getInt(Page.PAGE_ORDER));
final String permalink = page.optString(Page.PAGE_PERMALINK).trim();
String permalink = page.optString(Page.PAGE_PERMALINK).trim();
permalink = StringUtils.replace(permalink, " ", "-");
newPage.put(Page.PAGE_PERMALINK, permalink);
page.put(Page.PAGE_ICON, page.optString(Page.PAGE_ICON));

Expand Down Expand Up @@ -188,7 +190,8 @@ public String addPage(final JSONObject requestJSONObject) throws ServiceExceptio
final int maxOrder = pageRepository.getMaxOrder();
page.put(Page.PAGE_ORDER, maxOrder + 1);

final String permalink = page.optString(Page.PAGE_PERMALINK);
String permalink = page.optString(Page.PAGE_PERMALINK);
permalink = StringUtils.replace(permalink, " ", "-");
if (permalinkQueryService.exist(permalink)) {
if (transaction.isActive()) {
transaction.rollback();
Expand Down

0 comments on commit 1609973

Please # to comment.