Kebab file names

This commit is contained in:
Angelos Chalaris
2023-04-27 21:58:35 +03:00
parent 1d189c709a
commit 61200d90c4
440 changed files with 0 additions and 0 deletions

21
snippets/get-base-url.md Normal file
View File

@ -0,0 +1,21 @@
---
title: Get base URL
tags: string,browser,regexp
author: chalarangelo
cover: compass
firstSeen: 2020-05-03T12:20:54+03:00
lastUpdated: 2021-01-03T20:32:13+02:00
---
Gets the current URL without any parameters or fragment identifiers.
- Use `String.prototype.replace()` with an appropriate regular expression to remove everything after either `'?'` or `'#'`, if found.
```js
const getBaseURL = url => url.replace(/[?#].*$/, '');
```
```js
getBaseURL('http://url.com/page?name=Adam&surname=Smith');
// 'http://url.com/page'
```