File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 11/**
22 * @license
3- * Copyright 2018 Google LLC. All Rights Reserved.
3+ * Copyright 2019 Google LLC. All Rights Reserved.
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
@@ -335,3 +335,21 @@ export function getModelArtifactsInfoForJSON(modelArtifacts: ModelArtifacts):
335335 modelArtifacts . weightData . byteLength ,
336336 } ;
337337}
338+
339+ /**
340+ * Make Base64 string URL safe by replacing `+` with `-` and `/` with `_`.
341+ *
342+ * @param str Base64 string to make URL safe.
343+ */
344+ export function urlSafeBase64 ( str : string ) : string {
345+ return str . replace ( / \+ / g, '-' ) . replace ( / \/ / g, '_' ) ;
346+ }
347+
348+ /**
349+ * Revert Base64 URL safe changes by replacing `-` with `+` and `_` with `/`.
350+ *
351+ * @param str URL safe Base string to revert changes.
352+ */
353+ export function urlUnsafeBase64 ( str : string ) : string {
354+ return str . replace ( / - / g, '+' ) . replace ( / _ / g, '/' ) ;
355+ }
You can’t perform that action at this time.
0 commit comments