• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.net;
6 
7 import androidx.annotation.VisibleForTesting;
8 
9 import org.jni_zero.JNINamespace;
10 import org.jni_zero.NativeMethods;
11 
12 /** Class to access the GURL library from java. */
13 @JNINamespace("net")
14 public final class GURLUtils {
15 
16     /**
17      * Get the origin of an url: Ex getOrigin("http://www.example.com:8080/index.html?bar=foo")
18      * would return "http://www.example.com:8080/". It will return an empty string for an
19      * invalid url.
20      *
21      * @return The origin of the url
22      */
getOrigin(String url)23     public static String getOrigin(String url) {
24         return GURLUtilsJni.get().getOrigin(url);
25     }
26 
27     @VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)
28     @NativeMethods
29     public interface Natives {
getOrigin(String url)30         String getOrigin(String url);
31     }
32 }
33