Skip to content

Commit 967272f

Browse files
Merge pull request #162 from yy34/patch-5
URL objects
2 parents fa8490a + 9cb8628 commit 967272f

File tree

1 file changed

+36
-37
lines changed

1 file changed

+36
-37
lines changed

5-network/06-url/article.md

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11

2-
# URL objects
2+
# URL yapısı
33

4-
The built-in [URL](https://url.spec.whatwg.org/#api) class provides a convenient interface for creating and parsing URLs.
54

6-
There are no networking methods that require exactly an `URL` object, strings are good enough. So technically we don't have to use `URL`. But sometimes it can be really helpful.
5+
Yerleşik [URL](https://url.spec.whatwg.org/#api) sınıfı, URL'leri oluşturmak ve ayrıştırmak için uygun bir arayüz sağlar.
76

8-
## Creating an URL
7+
Tam olarak bir `URL` nesnesi gerektiren ağ oluşturma yöntemi yoktur, dizeler(strings) yeterince iyidir. Yani teknik olarak `URL` kullanmak zorunda değiliz. Ama bazen gerçekten yardımcı olabilir.
98

10-
The syntax to create a new URL object:
9+
## URL oluşturma
10+
11+
Yeni bir URL nesnesi oluşturmak için sözdizimi:
1112

1213
```js
1314
new URL(url, [base])
1415
```
1516

16-
- **`url`** -- the URL string or path (if base is set, see below).
17-
- **`base`** -- an optional base, if set and `url` has only path, then the URL is generated relative to `base`.
17+
- **`url`** -- URL'nin dizesi veya yolu (temel ayarlanmışsa, aşağıya bakın).
18+
- **`base`** -- isteğe bağlı, base ayarlanmış ve `url`'de yalnızca yol varsa bu durumda URL `base`'e göre yani tabana göre oluşturulur.
1819

19-
For example, these two URLs are same:
20+
Örneğin, bu iki URL aynı:
2021

2122
```js run
2223
let url1 = new URL('https://javascript.info/profile/admin');
@@ -26,7 +27,7 @@ alert(url1); // https://javascript.info/profile/admin
2627
alert(url2); // https://javascript.info/profile/admin
2728
```
2829

29-
Переход к пути относительно текущего URL:
30+
Mevcut URL'ye göre bir yola ata:
3031

3132
```js run
3233
let url = new URL('https://javascript.info/profile/admin');
@@ -35,8 +36,7 @@ let testerUrl = new URL('tester', url);
3536
alert(testerUrl); // https://javascript.info/profile/tester
3637
```
3738

38-
39-
The `URL` object immediately allows us to access its components, so it's a nice way to parse the url, e.g.:
39+
`URL` nesnesi, bileşenlerine anında erişmemizi sağlar, bu nedenle URL'yi ayrıştırmanın güzel bir yoludur.
4040

4141
```js run
4242
let url = new URL('https://javascript.info/url');
@@ -46,47 +46,46 @@ alert(url.host); // javascript.info
4646
alert(url.pathname); // /url
4747
```
4848

49-
Here's the cheatsheet:
49+
İşte kopya kağıdı:
5050

5151
![](url-object.svg)
5252

53-
- `href` is the full url, same as `url.toString()`
54-
- `protocol` ends with the colon character `:`
55-
- `search` - a string of parameters, starts with the question mark `?`
56-
- `hash` starts with the hash character `#`
57-
- there are also `user` and `password` properties if HTTP authentication is present.
53+
- `href` tam url, `url.toString()` ile aynı
54+
- `protocol` iki nokta üst üste karakteri ile biter `:`
55+
- `search` - bir dizi parametre, soru işaretiyle başlar `?`
56+
- `hash` karma karakterle başlar `#`
57+
- HTTP kimlik doğrulaması varsa `user` ve `password` özellikleri de vardır.
5858

5959

60-
```smart header="We can use `URL` everywhere instead of a string"
61-
We can use an `URL` object in `fetch` or `XMLHttpRequest`, almost everywhere where a string url is expected.
60+
```smart header="Bir string yerine her yerde `URL` kullanabiliriz"
61+
`fetch` veya `XMLHttpRequest`'te, bir string url'nin beklendiği hemen hemen her yerde bir `URL` nesnesi kullanabiliriz.
62+
63+
Yöntemlerin büyük çoğunluğunda otomatik olarak bir stringe dönüştürülür.
6264

63-
In the vast majority of methods it's automatically converted to a string.
64-
```
6565

66-
## SearchParams "?..."
66+
## Arama Parametreleri "?..."
6767

68-
Let's say we want to create an url with given search params, for instance, `https://google.com/search?query=JavaScript`.
68+
Verilen arama parametreleriyle bir url oluşturmak istediğimizi varsayalım, örneğin, `https://google.com/search?query=JavaScript`.
6969

70-
They must be correctly encoded to include non-latin charcters, spaces etc.
70+
Latin olmayan karakterleri, boşlukları vb. içerecek şekilde doğru kodlanmaları gerekir.
7171

72-
Some time ago, before `URL` objects appeared, we'd use built-in functions `encodeURIComponent/decodeURIComponent`. They have some problems, but now that doesn't matter.
72+
Bir süre önce, `URL` nesneler ortaya çıkmadan önce yerleşik işlevleri kullanırdık encodeURIComponent/decodeURIComponent. Bazı sorunları var ama artık bu önemli değil.
7373

74-
There's URL property for that: `url.searchParams` is an object of type [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams).
74+
Bunun için URL özelliği var: `url.searchParams` bu [URLSearchParams](https://url.spec.whatwg.org/#urlsearchparams) türünde bir nesnedir.
7575

76-
It provides convenient methods for search parameters:
76+
Arama parametreleri için uygun yöntemler sağlar:
7777

78-
- **`append(name, value)`** -- add the parameter,
79-
- **`delete(name)`** -- remove the parameter,
80-
- **`get(name)`** -- get the parameter,
81-
- **`getAll(name)`** -- get all parameters with that name (if many, e.g. `?user=John&user=Pete`),
82-
- **`has(name)`** -- check for the existance of the parameter,
83-
- **`set(name, value)`** -- set/replace the parameter,
84-
- **`sort()`** -- sort parameters by name, rarely needed,
85-
- ...and also iterable, similar to `Map`.
78+
- **`append(name, value)`** -- parametre ekleme,
79+
- **`delete(name)`** -- parametreyi silme,
80+
- **`get(name)`** -- parametreyi alma,
81+
- **`getAll(name)`** -- bu isimdeki tüm parametreleri al (eğer çoksa örnek: `?user=John&user=Pete`),
82+
- **`has(name)`** -- parametrenin varlığını kontrol etme,
83+
- **`set(name, value)`** -- parametreyi ayarlama / değiştirme,
84+
- **`sort()`** -- parametreleri ada göre sırala, nadiren gerekli...
8685

87-
So, `URL` object also provides an easy way to operate on url parameters.
86+
Dolayısıyla `URL` nesnesi, url parametreleri üzerinde çalışmanın kolay bir yolunu da sağlar.
8887

89-
For example:
88+
Örneğin:
9089

9190
```js run
9291
let url = new URL('https://google.com/search');

0 commit comments

Comments
 (0)