-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Share the displayed folder even from path ending with /
- Loading branch information
Showing
5 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Get the path to share the displayed folder | ||
* @param {string} pathname Current path | ||
* @returns Next path | ||
*/ | ||
export function getPathToShareDisplayedFolder(pathname) { | ||
return `${pathname}${pathname.endsWith('/') ? '' : '/'}share` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { getPathToShareDisplayedFolder } from 'drive/web/modules/drive/Toolbar/share/helpers' | ||
|
||
describe('getPathToShareDisplayedFolder', () => { | ||
it('should return path to displayed folder share modal', () => { | ||
expect(getPathToShareDisplayedFolder('/path/to/folder/123')).toBe( | ||
'/path/to/folder/123/share' | ||
) | ||
}) | ||
|
||
it('should return correct path if pathname ends with /', () => { | ||
expect(getPathToShareDisplayedFolder('/path/to/folder/123/')).toBe( | ||
'/path/to/folder/123/share' | ||
) | ||
}) | ||
}) |