Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Handle undefined
pathname
in generateWebLink()
method
The URL javascript object does not support undefined `pathname`. This member should be an empty string (transformed to `/`) or have a value ```js const url = new URL('https://cozy.io') console.log(url.pathname) // prints '/' console.log(url.toString()) // prints 'https://cozy.io/' url.pathname = undefined console.log(url.pathname) // prints '/undefined' console.log(url.toString()) // prints 'https://cozy.io/undefined' url.pathname = '' console.log(url.pathname) // prints '/' console.log(url.toString()) // prints 'https://cozy.io/' url.pathname = ensureFirstSlash(undefined) console.log(url.pathname) // prints '/' console.log(url.toString()) // prints 'https://cozy.io/' ``` By using 'ensureFirstSlash' method we ensure that the caller can pass undefined `pathname` without negative side effect
- Loading branch information