generated from Seekra/repository-template
refactor(settings): move setttings path normalization utility to a separate file
Moved the normalizePagePath utility from the settings page composable to a separate utility file and restructured tests accordingly.
This commit is contained in:
@@ -14,19 +14,9 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { getSettingsPagePathSegments } from '../utils/settingsPage';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
export const normalizePagePath = function normalizePagePath (path) {
|
||||
if (typeof path !== 'string') return [];
|
||||
return path
|
||||
.replace(/^\.+|\.+$/g, '')
|
||||
.split('.')
|
||||
.map(
|
||||
(segment) => segment.replace(/[^a-zA-Z0-9-]/g, '')
|
||||
)
|
||||
.filter(Boolean);
|
||||
};
|
||||
|
||||
export const useSettingsPage = function useSettingsPage () {
|
||||
const router = useRouter();
|
||||
|
||||
@@ -34,7 +24,7 @@ export const useSettingsPage = function useSettingsPage () {
|
||||
return router.push({
|
||||
name: 'settings',
|
||||
params: {
|
||||
rest: normalizePagePath(pagePath)
|
||||
rest: getSettingsPagePathSegments(pagePath)
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user