view util.go @ 1:76695bcbe426

write cmd
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Tue, 01 Dec 2020 20:30:06 +0900
parents
children af840bc25791
line wrap: on
line source

package growsync

import (
	"path/filepath"
	"strings"
)

func convertGrowiSystemPath(inputPath string) string {
	/*
		iputPath: Gears -> /Gears
		inputPath: Gears/CbC/hoge.md -> /Gears/CbC/hoge
	*/

	outputPATH := inputPath

	if index := strings.Index(inputPath, "/"); index != 0 {
		outputPATH = "/" + inputPath
	}

	if strings.HasSuffix(outputPATH, ".md") {
		outputPATH = strings.TrimSuffix(outputPATH, filepath.Ext(outputPATH))
	}

	return outputPATH
}