mirror of
https://github.com/larksuite/cli.git
synced 2026-07-06 16:18:05 +08:00
* fix(wiki): surface real node url for +node-create / +node-copy The create-node and copy-node OpenAPI responses carry a real `url` field (present in practice though absent from the documented schema). Both shortcuts ignored it: +node-create synthesized a link via BuildResourceURL, and +node-copy emitted no URL at all. Parse `url` into the shared wikiNodeRecord and add a wikiNodeURL helper that prefers the response url, falling back to BuildResourceURL only when it is blank. Wire +node-create and +node-copy to the helper so both surface the canonical link when available. Change-Id: I0ca5f91b02c24e81d083793e6a8e4f8c966aeec3 * refactor(wiki): move wikiNodeURL to shared wiki_helpers.go The helper is consumed by both +node-create and +node-copy, so its placement should reflect the broader usage rather than living in the create command's file. Pure move; no behavior change. Change-Id: I9990c12da042f631fe2519911c6a9d663fd5c22b
29 lines
852 B
Go
29 lines
852 B
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package wiki
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/larksuite/cli/internal/core"
|
|
"github.com/larksuite/cli/shortcuts/common"
|
|
)
|
|
|
|
// wikiNodeURL returns the user-facing link for a wiki node. The create/copy
|
|
// OpenAPI responses carry a real `url` (undocumented in the server-docs schema
|
|
// but present in practice); prefer it so the CLI surfaces the canonical link.
|
|
// Fall back to BuildResourceURL synthesis only when the response omits it.
|
|
//
|
|
// Shared by +node-create and +node-copy, hence kept here rather than in either
|
|
// command's file.
|
|
func wikiNodeURL(brand core.LarkBrand, node *wikiNodeRecord) string {
|
|
if node == nil {
|
|
return ""
|
|
}
|
|
if u := strings.TrimSpace(node.URL); u != "" {
|
|
return u
|
|
}
|
|
return common.BuildResourceURL(brand, "wiki", node.NodeToken)
|
|
}
|