mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-18 04:27:02 +02:00
24 lines
831 B
JavaScript
24 lines
831 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { ensureTrailingSlash, sanitizePath } from 'core/utils/sanitize-path';
|
|
|
|
module('Unit | Utility | sanitize-path', function () {
|
|
test('it removes spaces and slashes from either side', function (assert) {
|
|
assert.strictEqual(
|
|
sanitizePath(' /foo/bar/baz/ '),
|
|
'foo/bar/baz',
|
|
'removes spaces and slashes on either side'
|
|
);
|
|
assert.strictEqual(sanitizePath('//foo/bar/baz/'), 'foo/bar/baz', 'removes more than one slash');
|
|
});
|
|
|
|
test('#ensureTrailingSlash', function (assert) {
|
|
assert.strictEqual(ensureTrailingSlash('foo/bar'), 'foo/bar/', 'adds trailing slash');
|
|
assert.strictEqual(ensureTrailingSlash('baz/'), 'baz/', 'keeps trailing slash if there is one');
|
|
});
|
|
});
|