Skip to content

Commit 73cbfcf

Browse files
committed
adjust utils
1 parent afb27d8 commit 73cbfcf

File tree

1 file changed

+12
-8
lines changed
  • web/common/src/components/Lineage

1 file changed

+12
-8
lines changed

web/common/src/components/Lineage/utils.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,22 @@ export type TransformEdgeFn<
7272
targetColumnId?: PortId,
7373
) => LineageEdge<TEdgeData>
7474

75-
export function toID<TReturn extends string>(...args: string[]) {
76-
return args.join('.') as TReturn
75+
// ID generated from toInternalID is meant to be used only internally to identify nodes, edges and ports within the graph
76+
// Do not rely on the ID to be a valid URL, or anythjin outside of the graph
77+
export function toInternalID<TReturn extends string>(
78+
...args: string[]
79+
): TReturn {
80+
return encodeURI(args.filter(Boolean).join('.')) as TReturn
7781
}
7882

79-
export function toNodeID(...args: string[]) {
80-
return encodeURI(toID(...args)) as NodeId
83+
export function toNodeID(...args: string[]): NodeId {
84+
return toInternalID<NodeId>(...args)
8185
}
8286

83-
export function toEdgeID(...args: string[]) {
84-
return encodeURI(toID(...args)) as EdgeId
87+
export function toEdgeID(...args: string[]): EdgeId {
88+
return toInternalID<EdgeId>(...args)
8589
}
8690

87-
export function toPortID(...args: string[]) {
88-
return encodeURI(toID(...args)) as PortId
91+
export function toPortID(...args: string[]): PortId {
92+
return toInternalID<PortId>(...args)
8993
}

0 commit comments

Comments
 (0)